home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 35 / Amiga Format AFCD35 (Issue 119, Jan 1999).iso / -in_the_mag- / reader_requests / fredobbutils / bbsrc / resettool_1.0.s < prev    next >
Text File  |  1998-11-06  |  75KB  |  4,389 lines

  1. ;
  2. ;RESET-TOOL v1.0 by Frédo (fbas@club-internet.fr) '95-97
  3. ;
  4. ;PUBLIC DOMAIN - Do what you want with this thingy!
  5. ;
  6. ;Another resident monitor... UNFINISHED as I don't have the time!
  7. ;
  8. ;TODO:
  9. ;    - add de-installation routine
  10. ;    - Improve disassembly routines
  11. ;    - Implement assemble instruction
  12. ;    - Implement command history
  13. ;    - Improve the 'si' (System Info) command
  14. ;    - Improve/debug the '?' (Calculate) command
  15. ;    - Improve everything, fix the numerous bugs!
  16. ;    - and anything else you want...
  17. ;
  18. ;I WOULD BE HAPPY TO SEE IMPROVED VERSIONS OF THIS!!
  19. ;SO IF YOU DO IMPROVE IT OR USE IT, TELL ME.
  20. ;
  21. ;Assemble with PhxAss or AsmOne, Trash'mOne
  22.  
  23.     incdir    ASM:/Include/
  24.     include equ.s
  25.     include exec/types.i
  26.     include exec/resident.i
  27.     include exec/lists.i
  28.     include exec/memory.i
  29.     include exec/execbase.i
  30.  
  31. DBUG=1    ;0 to disable debug mode
  32.  
  33.     IFEQ    DBUG
  34.  
  35.     STRUCTURE    InitGlobals,0
  36.         APTR    ig_memlist
  37.         APTR    ig_resdatastruct
  38.         APTR    ig_resident
  39.         APTR    ig_segment
  40.         APTR    ig_nextseg
  41.         APTR    ig_segsize
  42.         LABEL    ig_size
  43. StringSizeMax=20
  44.     STRUCTURE    myresident,RT_SIZE
  45.         APTR    mr_reslist
  46.         APTR    mr_listend
  47.         STRUCT    mr_name,StringSizeMax
  48.         STRUCT    mr_idstring,StringSizeMax*2
  49.         LABEL    mr_size
  50.  
  51.     BITDEF    MEM,RESET,MEMB_CHIP
  52.  
  53. VERSION=1
  54. PRI=-55
  55.  
  56. ;Install Reset-Tool into memory (as a resident module)
  57. InitRes:
  58.     moveq    #ig_size,d0
  59.     move.l    #MEMF_PUBLIC!MEMF_CLEAR,d1
  60.     move.l    4.w,a6
  61.     jsr    AllocMem(a6)
  62.     move.l    d0,a5
  63.     move.l    a5,d0
  64.     beq.w    Init_NoGlobalMem
  65.     moveq    #mr_size,d0
  66.     move.l    #MEMF_PUBLIC!MEMF_CLEAR!MEMF_RESET,d1
  67.     jsr    AllocMem(a6)
  68.     move.l    d0,ig_resident(a5)
  69.     beq.w    Init_NoResidentMem
  70.  
  71.     lea    InitRes-4(pc),a0
  72.     lea    ResetSegStart(pc),a1
  73.     move.l    (a0),ig_nextseg(a5)
  74.     move.l    (a0),4(a1)
  75.     clr.l    (a0)
  76.     move.l    -4(a0),d0
  77.     move.l    d0,ig_segsize(a5)
  78.     move.l    #ResetSegStart-InitRes+8,d1
  79.     sub.l    d1,d0
  80.     move.l    d0,(a1)
  81.     move.l    d1,-4(a0)
  82.  
  83.     lea    ResetSegStart+4(pc),a0
  84.     move.l    a0,ig_segment(a5)
  85.     moveq    #1,d0
  86.     bsr.w    MakeMemList
  87.     move.l    d0,ig_memlist(a5)
  88.     beq.b    Init_NoMemEntry
  89.     move.l    ig_resident(a5),ME_ADDR(a0)
  90.     move.l    #mr_size,ME_LENGTH(a0)
  91.     move.l    ig_resident(a5),a0
  92.     move.l    ig_memlist(a5),a1
  93.     move.l    ig_segment(a5),d0
  94.     bsr.w    MakeReset
  95. *** Message d'installation
  96.     lea    dosname(pc),a1
  97.     moveq    #0,d0
  98.     move.l    4.w,a6
  99.     jsr    OpenLibrary(a6)
  100.     move.l    d0,d7
  101.     beq.b    .nodos
  102.     move.l    d7,a6
  103.     jsr    Output(a6)
  104.     move.l    d0,d6
  105.     beq.b    .cldos
  106.     lea    ResidentName(pc),a0
  107.     bsr.b    prnt
  108.     lea    Install.txt(pc),a0
  109.     bsr.b    prnt
  110. .cldos
  111.     move.l    d7,a1
  112.     move.l    4.w,a6
  113.     jsr    CloseLibrary(a6)
  114. .nodos
  115.     bra.b    Init_Fin
  116.  
  117. * afficher un text-string (terminée par 0)
  118. * a0: adr string
  119. * d6: output handle
  120. * d7: dosbase
  121. prnt
  122.     move.l    a0,d2
  123.     moveq    #-1,d3
  124. .lop    addq.l    #1,d3
  125.     tst.b    (a0)+
  126.     bne.b    .lop
  127.     move.l    d6,d1
  128.     move.l    d7,a6
  129.     jmp    Write(a6)
  130.  
  131. Init_NoMemEntry:
  132.     lea    InitRes-8(pc),a0
  133.     move.l    ig_segsize(a5),(a0)
  134.     move.l    ig_nextseg(a5),4(a0)
  135.     move.l    ig_resident(a5),a1
  136.     moveq    #mr_size,d0
  137.     move.l    4.w,a6
  138.     jsr    FreeMem(a6)
  139. Init_NoResidentMem:
  140. Init_Fin:
  141.     moveq    #ig_size,d0
  142.     move.l    a5,a1
  143.     move.l    4.w,a6
  144.     jsr    FreeMem(a6)
  145. Init_NoGlobalMem:
  146.     moveq    #0,d0
  147.     rts
  148.  
  149. MakeMemList:
  150.     movem.l a2-a3/d2-d4,-(sp)
  151.     move.l    a0,a2
  152.     move    d0,d2
  153.     bsr.b    ScanSegMemList
  154.     move    d0,d3
  155.     add    d0,d2
  156.     addq    #1,d2
  157.     move    d2,d0
  158.     mulu    #ME_SIZE,d0
  159.     add.l    #ML_SIZE,d0
  160.     move.l    d0,d4
  161.     move.l    #MEMF_CLEAR!MEMF_PUBLIC!MEMF_RESET,d1
  162.     jsr    AllocMem(a6)
  163.     tst.l    d0
  164.     beq.b    .end
  165.     move.l    d0,a3
  166.     move    d2,ML_NUMENTRIES(a3)
  167.     lea    ML_ME(a3),a0
  168.     move.l    d0,ME_ADDR(a0)
  169.     move.l    d4,ME_LENGTH(a0)
  170.     addq.l    #ME_SIZE,a0
  171.     bra.b    .do
  172. .loop
  173.     lea    -4(a2),a1
  174.     move.l    a1,ME_ADDR(a0)
  175.     move.l    (a1),ME_LENGTH(a0)
  176.     addq.l    #ME_SIZE,a0
  177.     move.l    (a2),d0
  178.     lsl.l    #2,d0
  179.     move.l    d0,a2
  180. .do
  181.     dbf    d3,.loop
  182.     move.l    a3,d0
  183. .end
  184.     movem.l (sp)+,a2-a3/d2-d4
  185.     rts
  186.  
  187. ScanSegMemList:
  188.     moveq    #1,d0
  189. .loop    move.l    (a0),d1
  190.     beq.b    .end
  191.     lsl.l    #2,d1
  192.     move.l    d1,a0
  193.     addq    #1,d0
  194.     bra.b    .loop
  195. .end    rts
  196.  
  197. MakeReset:
  198.     movem.l a2-a4,-(sp)
  199.     move.l    a0,a2
  200.     move.l    a1,a3
  201.     addq.l    #4,d0
  202.     move.l    d0,a4
  203.     move.l    a2,a1
  204.  
  205. ;save ptr to Resident structure
  206.     move.l    a1,myresptr
  207.  
  208.     lea    Resident(pc),a0
  209.     moveq    #RT_SIZE,d0
  210.     jsr    CopyMem(a6)
  211.     move.l    a2,RT_MATCHTAG(a2)
  212.     move.l    a2,mr_reslist(a2)
  213.     move.l    a4,RT_INIT(a2)
  214.     lea    ResidentName(pc),a0
  215.     lea    mr_name(a2),a1
  216.     moveq    #StringSizeMax-1,d0
  217.     jsr    CopyMem(a6)
  218.     lea    ResidentIDString(pc),a0
  219.     lea    mr_idstring(a2),a1
  220.     moveq    #(StringSizeMax*2)-1,d0
  221.     jsr    CopyMem(a6)
  222.  
  223.     lea    mr_name(a2),a0
  224.     move.l    a0,RT_NAME(a2)
  225.     lea    mr_idstring(a2),a0
  226.     move.l    a0,RT_IDSTRING(a2)
  227. ;    clr.l    RT_IDSTRING(a2)
  228.     lea    mr_size(a2),a0
  229.     move.l    a0,RT_ENDSKIP(a2)
  230.     move.l    KickTagPtr(a6),d0
  231.     beq.b    .ResMod
  232.     bset    #31,d0
  233. .ResMod
  234.     move.l    d0,mr_listend(a2)
  235.     lea    mr_reslist(a2),a0
  236.     move.l    a0,KickTagPtr(a6)
  237.     move.l    KickMemPtr(a6),(a3)
  238.     move.l    a3,KickMemPtr(a6)
  239.     jsr    SumKickData(a6)
  240.     move.l    d0,KickCheckSum(a6)
  241.     movem.l (sp)+,a2-a4
  242.     rts
  243.  
  244. *** Structure Resident
  245. Resident:
  246.     dc.w    RTC_MATCHWORD    ;rt_MatchWord
  247.     dc.l    0        ;rt_MatchTag
  248.     dc.l    0        ;rt_EndSkip
  249.     dc.b    RTF_COLDSTART    ;rt_Flags
  250.     dc.b    VERSION     ;rt_Version
  251.     dc.b    NT_UNKNOWN    ;rt_Type
  252.     dc.b    PRI        ;rt_Pri
  253.     dc.l    0        ;rt_Name
  254.     dc.l    0        ;rt_IDString
  255.     dc.l    0        ;rt_Init
  256.  
  257. residentlist:dc.l Resident,0
  258.  
  259. dosname:    dc.b 'dos.library',0
  260. Install.txt:    dc.b ' ...installed!',$a,0
  261. Rem.txt:    dc.b ' ...removed!',$a,0
  262. ResidentName:    dc.b 'RESET-TOOL',0
  263. ResidentNameLen=*-ResidentName
  264. ResidentIDString:dc.b 'rt 1.0 (1.1.96) by Frédéric BASSALER',$a,0
  265.     even
  266. ResetSegStart:dc.l 0,0
  267.  
  268.     ENDC
  269.  
  270.  
  271. ResetProg:
  272.  
  273. ;here follows the resident part of the program
  274.  
  275. *************************************************
  276. *        RESET-TOOL        V1.0    *
  277. *-----------------------------------------------*
  278. * Classe: Moniteur de mémoire            *
  279. * Auteur: Frédéric Bassaler            *
  280. * Date:   Commençé en Mai 1995            *
  281. *-----------------------------------------------*
  282. * Config: OS 1.3 ou supérieur            *
  283. * (testé sous 1.3 et 2.04)            *
  284. *************************************************
  285.  
  286.     include exec/ports.i
  287.     include exec/interrupts.i
  288.     include exec/tasks.i
  289. ;    include exec/execbase.i
  290.     include graphics/text.i
  291.     include graphics/gfx.i
  292.     include graphics/rastport.i
  293.     include intuition/intuition.i
  294.  
  295.     rsreset
  296. mytask    rs.l    1
  297. ;oldsysstack rs.l 1
  298. oldtrap rs.l    1
  299. trapadr rs.l    1
  300. savesp    rs.l    1
  301. olddma    rs.w    1
  302. oldirq    rs.w    1
  303. oldint    rs.w    1
  304. intbase rs.l    1
  305. gfxbase rs.l    1
  306. scrbase rs.l    1
  307. winbase rs.l    1
  308. rast    rs.l    1
  309. x_pos    rs.w    1
  310. y_pos    rs.w    1
  311. x_max    rs.w    1
  312. y_max    rs.w    1
  313. x_rsize rs.w    1
  314. y_rsize rs.w    1
  315. x_org    rs.w    1
  316. y_org    rs.w    1
  317. combuf    rs.l    1
  318. comlen    rs.w    1
  319. maxcomlen rs.w    1
  320. oldptr    rs.l    1
  321. endadr    rs.l    1
  322. lastdis rs.l    1
  323. unit0    rs.l    1
  324. unit1    rs.l    1
  325. unit2    rs.l    1
  326. unit3    rs.l    1
  327. curunit rs.l    1
  328. defunit rs.l    1
  329. dflag    rs.b    1
  330. ascflag rs.b    1
  331. conport rs.b    34
  332. conio    rs.b    48
  333. keymap    rs.b    32
  334. inputevent rs.b 22
  335. trkbuf    rs.b    512*11*2
  336. outbuf    rs.b    512*4
  337. binbuf    rs.b    48
  338. VARSIZE rs.w    0
  339.  
  340. * dimensions écran/fenètre
  341. Width=640    ;screen width
  342. Height=-1    ;screen height
  343. Depth=2        ;screen depth
  344.  
  345. ;NEWKEYMAP=0
  346.  
  347. Main:
  348.     btst    #6,$bfe001    ;leftmousebutton during reboot to skip
  349.     bne.s    .enter
  350.     rts
  351. * passer en mode superviseur
  352. .superv move    #$2700,sr
  353.     move    sr,srreg
  354.     rte
  355. .enter
  356.     movem.l d0-a7,regs    ;sauver registres
  357.     movem.l d0-a6,-(sp)
  358.     lea    .superv(pc),a5
  359.     move.l    4.w,a6
  360. ;    jsr    Supervisor(a6)
  361. * Mettre le bit BLIPRI de DMACON à 1
  362. * pour que le blitter ait la priorité sur le CPU
  363. * (gain de vitesse à l'affichage)
  364. ;    lea    $dff000,a0
  365. ;    move    2(a0),d0
  366. ;    or    #$87f0,d0
  367. ;    move    d0,$96(a0)
  368. * allouer buffer pour variables globales
  369.     move.l    #VARSIZE,d0
  370.     move.l    #$10001,d1
  371. ;     move.l  4.w,a6
  372.     jsr    AllocMem(a6)
  373.     move.l    d0,a5
  374.     move.l    a5,d0
  375.     beq    quit
  376.     lea    VARS(pc),a0
  377.     move.l    d0,(a0)
  378.     move.l    ThisTask(a6),mytask(a5)
  379. * ouvrir trackdisk pour toutes les unités disponibles
  380.     lea    unit0(a5),a4
  381.     moveq    #3,d3
  382.     moveq    #0,d4
  383. .op
  384.     move.l    d4,d0
  385.     bsr    OpenUnit
  386.     move.l    d0,(a4)+
  387.     addq.l    #1,d4
  388.     dbf    d3,.op
  389.  
  390.     move.l    unit0(a5),curunit(a5)    ;unité courante par défaut = df0:
  391. *** open libs
  392.     lea    gfxname(pc),a1
  393.     moveq    #0,d0
  394.     jsr    OpenLibrary(a6)
  395.     move.l    d0,gfxbase(a5)
  396.     beq    cltd
  397.     lea    intname(pc),a1
  398.     moveq    #0,d0
  399.     jsr    OpenLibrary(a6)
  400.     move.l    d0,intbase(a5)
  401.     beq.w    cltd
  402. *** Open main screen & window
  403.     lea    New.Scr(pc),a0
  404.     move.l    intbase(a5),a6
  405.     jsr    OpenScreen(a6)
  406.     move.l    d0,scrbase(a5)
  407.     beq    cltd
  408.     move.l    d0,a0
  409.     lea    44(a0),a0
  410.     lea    New.Pal(pc),a1
  411.     moveq    #2^Depth,d0
  412.     move.l    gfxbase(a5),a6
  413.     jsr    LoadRGB4(a6)
  414.  
  415.     move.l    scrbase(a5),a1
  416.     lea    New.Win(pc),a0
  417.     move    sc_Width(a1),nw_Width(a0)
  418.     move    sc_Height(a1),nw_Height(a0)
  419.     move.l    a1,nw_Screen(a0)
  420.     move.l    intbase(a5),a6
  421.     jsr    OpenWindow(a6)
  422.     move.l    d0,winbase(a5)
  423.     beq    clscr
  424. *** Open console
  425.     move.l    d0,a0
  426.     move.l    50(a0),rast(a5)    ;window->rastport
  427.     move.l    d0,d7
  428.     lea    conport(a5),a1
  429.     move.l    a1,-(sp)
  430.     move.l    mytask(a5),$10(a1)
  431.     move.l    4.w,a6
  432.     jsr    AddPort(a6)
  433.  
  434.     lea    conio(a5),a1
  435.     move.l    (sp)+,14(a1)
  436.     move.l    d7,40(a1)
  437.     move.l    #nw_SIZEOF,36(a1)
  438.     moveq    #0,d0
  439.     moveq    #0,d1
  440.     lea    consolename(pc),a0
  441.     jsr    OpenDevice(a6)
  442.     tst.l    d0
  443.     bne    clwin
  444.  
  445. ;    bsr    SetMap        ;set new keymap
  446.  
  447. *** installer handler trap
  448. ;    move.l    MyTask(a5),a1
  449. ;    move.l    tc_TrapCode(a1),oldtrap(a5)
  450. ;    lea    mytrap(pc),a0
  451. ;    move.l    a0,tc_TrapCode(a1)
  452. ;    clr.l    tc_TrapData(a1)
  453.  
  454. *** affiche main menu
  455. printmenu:
  456.     lea    main.txt(pc),a0
  457.     bsr    print
  458. ;last guru
  459.     move.l    4.w,a6
  460.     lea    514(a6),a0
  461.     tst.l    (a0)
  462.     beq.s    .no_failure
  463.     move.l    a0,a1
  464.     lea    lastalert.txt(pc),a0
  465.     bsr    printf
  466. .no_failure
  467. mainmenu:
  468.     bsr    prompt
  469.     lea    strbuf(pc),a0
  470.     move.l    a0,combuf(a5)
  471.     clr    comlen(a5)
  472.     moveq    #(strbuflen>>2)-1,d0
  473. .clr    clr.l    (a0)+
  474.     dbf    d0,.clr
  475. *** boucle principale: attente d'un ordre
  476. mainloop:
  477.     move.l    winbase(a5),a0
  478.     bsr.w    WaitMsg
  479.     cmp.l    #$400,d6
  480.     bne.s    mainloop
  481.  
  482.     btst    #7,d4        ;touche relachée?
  483.     bne.s    mainloop
  484.     move    d4,d0
  485.     and    #$60,d0
  486.     cmp    #$60,d0     ;shift, ctrl, etc..?
  487.     beq.s    mainloop
  488.  
  489.     cmp.b    #$5f,d4     ;help
  490.     beq.s    printmenu
  491.     cmp.b    #$4f,d4     ;flèche Gauche
  492.     beq.w    .cursorleft
  493.     cmp.b    #$4e,d4     ;flèche Droit
  494.     beq.w    .cursorright
  495.     cmp.b    #$4c,d4     ;flèche Haut
  496.     beq.s    .oldcommand
  497.  
  498.     bsr.w    ConvRawKey    ;convertir code rawkey en ascii
  499.     lea    string(pc),a0
  500.     move.b    (a0),d0
  501.     cmp.b    #$d,d0        ;cr?
  502.     beq.s    .getcommand
  503.     cmp.b    #8,d0        ;backspace?
  504.     beq.w    .dobackspace
  505.     cmp.b    #$1b,d0     ;esc?
  506.     beq.w    cls
  507.  
  508.     move.l    combuf(a5),a0
  509.     move.b    d0,(a0)+
  510.     move.l    a0,combuf(a5)
  511.     cmp    #strbuflen,comlen(a5)
  512.     bge.s    mainloop
  513.     addq    #1,comlen(a5)
  514.  
  515.     subq.l    #1,a0
  516.     bsr.w    print        ;afficher le caractère ascii
  517.     bra.s    mainloop
  518. .oldcommand
  519.     lea    oldcommand.txt(pc),a0
  520.     bsr    print
  521.     lea    oldbuf(pc),a0
  522.     move.l    a0,-(sp)
  523.     lea    strbuf(pc),a1
  524.     move.l    #strbuf,combuf(a5)
  525.     clr    comlen(a5)
  526.     move    #strbuflen-1,d0
  527. .restore_from_oldbuf
  528.     move.b    (a0)+,(a1)+
  529.     beq.s    .restore_done
  530.     addq.l    #1,combuf(a5)
  531.     addq    #1,comlen(a5)
  532.     dbf    d0,.restore_from_oldbuf
  533. .restore_done
  534.     move.l    (sp)+,a0
  535.     bsr    print
  536.     bra    mainloop
  537. .getcommand
  538.     lea    lf.txt(pc),a0
  539.     bsr    print
  540. * copier ligne de commande vers buffer de sauvegarde
  541.     lea    strbuf(pc),a0
  542.     move.l    a0,-(sp)
  543.     tst.b    (a0)
  544.     beq.s    .copy_done
  545.     lea    oldbuf(pc),a1
  546.     move    #strbuflen-1,d0
  547. .copy_to_oldbuf
  548.     move.b    (a0)+,(a1)+
  549.     beq.s    .copy_done
  550.     dbf    d0,.copy_to_oldbuf
  551. .copy_done
  552.     move.l    (sp)+,a0
  553.     moveq    #0,d7
  554.     move    comlen(a5),d7    ;long. ligne de commande
  555.     addq    #1,d7
  556.     move.b    (a0),d0     ;linefeed seul?
  557.     beq    mainmenu
  558.     move    (a0),d1
  559.     move.l    (a0),d2
  560.  
  561. * parse command
  562.     cmp.b    #'<',d0
  563.     beq    ReadBlocks
  564.     cmp.b    #'>',d0
  565.     beq    WriteBlocks
  566.     cmp.b    #'[',d0
  567.     beq    AllocMemory
  568.     cmp.b    #']',d0
  569.     beq    FreeMemory
  570.     cmp.b    #'?',d0
  571.     beq    Calculate
  572.  
  573.     cmp.l    #'KILL',d2
  574.     beq    UnInstall
  575.     cmp.l    #'fill',d2
  576.     beq    FillMem
  577.     cmp.l    #'find',d2
  578.     beq    FindMem
  579.     cmp.l    #'inst',d2
  580.     beq    InstallDisk
  581.     cmp    #'si',d1
  582.     beq    SysInfo
  583.     cmp    #'cl',d1
  584.     beq    ClearMem
  585.     cmp    #'du',d1
  586.     beq    ChangeUnit
  587.     cmp.b    #'x',d0
  588.     beq.w    CloseAll
  589.     cmp.b    #'m',d0
  590.     beq    MemDump
  591.     cmp.b    #'a',d0
  592.     beq    AsciiDump
  593.     cmp.b    #'c',d0
  594.     beq    CopMem
  595.     cmp.b    #'d',d0
  596.     beq    Dis
  597.     cmp.b    #'j',d0
  598.     beq    Jump
  599.     cmp.b    #'r',d0
  600.     beq    ShowRegs
  601.     cmp.b    #'e',d0
  602.     beq    EditMem
  603.     cmp.b    #'b',d0
  604.     beq    BlockCheckSum
  605.     cmp.b    #'l',d0
  606.     beq    ListResModules
  607.  
  608.     lea    badcommand.txt(pc),a0
  609.     bsr    print
  610.     bra.w    mainmenu
  611. .cursorleft
  612.     cmp.l    #strbuf,combuf(a5)
  613.     ble.s    .main
  614.     subq.l    #1,combuf(a5)
  615.     lea    cursorleft.txt(pc),a0
  616.     bra.s    .pr
  617. .cursorright
  618.     lea    cursorright.txt(pc),a0
  619.     bra.s    .pr
  620. .dobackspace
  621.     cmp.l    #strbuf,combuf(a5)
  622.     ble.s    .main
  623.     subq.l    #1,combuf(a5)
  624.     move.l    combuf(a5),a0
  625.     clr.b    (a0)
  626.     subq    #1,comlen(a5)
  627.     lea    backspace.txt(pc),a0
  628. .pr    bsr    print
  629. .main    bra    mainloop
  630.  
  631. *** fermer & libérer tout
  632. CloseAll:
  633. ;    move.l    mytask(a5),a1
  634. ;    move.l    oldtrap(a5),tc_TrapCode(a1)
  635. clcon
  636.     lea    conio(a5),a1
  637.     move.l    14(a1),-(sp)
  638.     move.l    4.w,a6
  639.     jsr    CloseDevice(a6)
  640.     move.l    (sp)+,a1
  641.     jsr    RemPort(a6)
  642. clwin
  643.     move.l    winbase(a5),d0
  644.     beq.b    clscr
  645.     move.l    d0,a0
  646.     move.l    intbase(a5),a6
  647.     jsr    CloseWindow(a6)
  648. clscr
  649.     move.l    scrbase(a5),d0
  650.     beq.b    cltd
  651.     move.l    d0,a0
  652.     move.l    intbase(a5),a6
  653.     jsr    CloseScreen(a6)
  654.     move.l    intbase(a5),a1
  655.     move.l    4.w,a6
  656.     jsr    CloseLibrary(a6)
  657.     move.l    gfxbase(a5),a1
  658.     jsr    CloseLibrary(a6)
  659. cltd
  660. * fermer toutes les unités de disk
  661. CloseDiskUnits:
  662.     lea    unit0(a5),a4
  663.     moveq    #3,d3
  664. .clu    move.l    (a4),a0
  665.     clr.l    (a4)+
  666.     bsr    CloseUnit
  667.     dbf    d3,.clu
  668. * retourner en mode utilisateur
  669. ;    move.l    oldsysstack(a5),d0
  670. ;    move.l    4.w,a6
  671. ;    jsr    -156(a6)    ;UserState()
  672. freevars:
  673. ;    move.l    VARS(pc),a1
  674.     move.l    a5,a1
  675.     move.l    #VARSIZE,d0
  676.     move.l    4.w,a6
  677.     jsr    FreeMem(a6)
  678. quit
  679.     movem.l (sp)+,d0-a6
  680.     rts
  681. notrack
  682.     move    #$f00,$dff180
  683.     bra.b    quit
  684.  
  685. WaitMsg:
  686.     move.l    a0,a4
  687.     move.l    86(a0),a0
  688.     move.l    a0,-(sp)
  689.     move.l    4.w,a6
  690.     jsr    WaitPort(a6)
  691.     move.l    (sp)+,a0
  692.     jsr    GetMsg(a6)
  693.     move.l    a4,a0
  694.     tst.l    d0
  695.     beq.s    WaitMsg
  696.     move.l    d0,a1
  697.     move.l    a1,-(sp)
  698.     jsr    ReplyMsg(a6)
  699.     move.l    (sp)+,a1
  700.     move.l    20(a1),d6    ;ie_class
  701.     move    24(a1),d4    ;ie_code
  702.     move    26(a1),d5    ;ie_qualifier
  703.     move.l    28(a1),d7    ;ie_itemaddress
  704.     rts
  705.  
  706. * Transformer le code rawkey en code ascii correspondant
  707. ConvRawKey:
  708.     move.l    a6,-(sp)
  709.     lea    conio(a5),a6    ;iorequest
  710.     move.l    20(a6),a6    ;device library
  711.     lea    inputevent(a5),a0
  712.     move.b    #1,4(a0)    ;ieclass_rawkey
  713.     move    d4,6(a0)    ;code rawkey
  714.     move    d5,8(a0)    ;qualifier: 1=lshift 2=rshift 8=ctrl
  715.     clr.l    (a0)        ;nxt=0
  716.     lea    string(pc),a1    ;buffer destination
  717.     moveq    #10,d1        ;nbre d'octets
  718.     suba.l    a2,a2
  719.     jsr    -48(a6)     ;RawKeyConvert()
  720.     move.l    (sp)+,a6
  721.     rts
  722. string    dcb.b    12,0
  723.     even
  724.  
  725. *** rechercher le prochain espace
  726. spc    cmp.b    #$20,(a0)+
  727.     beq.s    spc
  728.     subq.l    #1,a0
  729.     rts
  730.  
  731. *** Calculer une expression (pas encore au point!)
  732. Calculate:
  733.     addq.l    #1,a0
  734.     tst.b    (a0)
  735.     bne.s    .spc
  736.     moveq    #0,d0
  737.     bra.s    .calc_done
  738. .spc    bsr.s    spc
  739.  
  740.     bsr.s    Calc
  741. .calc_done
  742.     lea    .ascbuf(pc),a0
  743.     move.l    a0,-(sp)
  744.     move.l    d0,-(sp)    ;résultat
  745.     move.l    d0,-(sp)
  746.  
  747.     moveq    #3,d1
  748. .cop    rol.l    #8,d0
  749.     move.b    d0,(a0)+
  750.     dbf    d1,.cop
  751.     clr.b    (a0)
  752.  
  753.     lea    .ascbuf(pc),a0
  754.     moveq    #4,d0
  755.     bsr    Test
  756.  
  757.     move.l    sp,a1
  758.     lea    .str(pc),a0
  759.     bsr    printf
  760.  
  761.     move.l    (sp),d1
  762.     bsr    Long2BinString
  763.     bsr    print
  764.     add    #12,sp
  765.     lea    lf.txt(pc),a0
  766.     bsr    print
  767. .f
  768.     bra    mainmenu
  769. .badargs
  770.     bsr    BadArgs
  771.     bra.s    .f
  772. .str    dc.b    '$%08lx %10.10ld "%s" %%',0
  773. .ascbuf dcb.b    6,0
  774.     even
  775.  
  776. *****************************************
  777. *   Calculer une expression numérique    *
  778. *---------------------------------------*
  779. * Paramètres d'entrée:                  *
  780. * a0: adr. de l'expression à calculer   *
  781. *    (chaine ascii terminée par 0)    *
  782. *---------------------------------------*
  783. * En sortie:                *
  784. * d0: contient le résultat        *
  785. * d1: 0=ok, -1=erreur            *
  786. *****************************************
  787. Calc:
  788.     move.l    a4,-(sp)
  789.     lea    result(pc),a4
  790.     clr.l    (a4)
  791. * analyse des opérateurs
  792. .loop
  793.     moveq    #0,d0
  794.     move.b    (a0)+,d0
  795.     beq.w    .fin        ;0 de fin?
  796.     cmp.b    #'"',d0
  797.     beq.w    .ascii
  798.     cmp.b    #'(',d0
  799.     beq.s    .loop
  800.     cmp.b    #')',d0
  801.     beq.s    .loop
  802.     cmp.b    #'[',d0
  803.     beq.s    .loop
  804.     cmp.b    #']',d0
  805.     beq.s    .loop
  806.     cmp.b    #'/',d0
  807.     beq.w    .div
  808.     cmp.b    #':',d0
  809.     beq.w    .div
  810.     cmp.b    #'*',d0
  811.     beq.w    .mul
  812.     cmp.b    #'-',d0
  813.     beq.w    .moins
  814.     cmp.b    #'+',d0
  815.     beq.w    .plus
  816.     cmp.b    #'^',d0
  817.     beq.w    .power
  818.     cmp.b    #'!',d0
  819.     beq.w    .or
  820.     cmp.b    #'|',d0
  821.     beq.w    .or
  822.     cmp.b    #'&',d0
  823.     beq.w    .and
  824.     cmp.b    #'~',d0
  825.     beq.w    .not
  826.     cmp.b    #'>',d0
  827.     beq.w    .rot_right
  828.     cmp.b    #'<',d0
  829.     beq.w    .rot_left
  830.  
  831. .cv
  832.     btst    #6,$bfe001
  833.     beq.s    .fin
  834.  
  835.     subq.l    #1,a0
  836.     bsr.w    Convert
  837.     move.l    d1,(a4)
  838.     bra.w    .loop
  839. .ascii
  840.     move.l    a0,a1
  841. .ass    move.b    (a1)+,d0
  842.     beq.w    CalcErr     ;pas de guillemet de fin?
  843.     cmp.b    #'"',d0
  844.     bne.s    .ass
  845.     suba.l    a0,a1
  846.     move.l    a1,d0
  847.     subq    #1,d0
  848.     lea    .asciibuf(pc),a1
  849.     move.l    a1,-(sp)
  850. .copasc move.b    (a0)+,(a1)+
  851.     dbf    d0,.copasc
  852.     move.l    (sp)+,a1
  853.     move.l    (a1),(a4)
  854.     bra.w    .loop
  855. .fin
  856.     move.l    (a4),d0
  857.     move.l    (sp)+,a4
  858.     moveq    #0,d1
  859.     rts
  860.  
  861. .asciibuf dcb.b 8,0
  862.     even
  863. ;.parenth
  864. ;    bra.w    .loop
  865. .div
  866.     bsr.w    Convert
  867.     move.l    (a4),d0
  868.     tst.l    d1
  869.     beq.s    .zero
  870. ;    divs    d1,d0
  871. ;    ext.l    d0
  872.     bsr.w    Div32
  873.     move.l    d0,(a4)
  874. .zero
  875.     bra.w    .loop
  876. .mul
  877.     bsr.w    Convert
  878.     move.l    (a4),d0
  879. ;    muls    d1,d0
  880.     bsr.w    Mult32
  881.     move.l    d0,(a4)
  882.     bra.w    .loop
  883. .moins
  884.     bsr.w    Convert
  885.     move.l    (a4),d0
  886.     sub.l    d1,d0
  887.     move.l    d0,(a4)
  888.     bra.w    .loop
  889. .plus
  890.     bsr.w    Convert
  891.     move.l    (a4),d0
  892.     add.l    d1,d0
  893.     move.l    d0,(a4)
  894.     bra.w    .loop
  895. .power
  896.     bsr.w    Convert
  897.     move.l    (a4),d0
  898.     moveq    #1,d2
  899.     tst.l    d1        ;puissance = 0?
  900.     beq.s    .pow_done
  901. .pow
  902. ;    mulu    d0,d2
  903.     movem.l d0-d1,-(sp)
  904.     move.l    d2,d1
  905.     bsr.b    Mult32
  906.     move.l    d0,d2
  907.     movem.l (sp)+,d0-d1
  908.     subq    #1,d1
  909.     bne.s    .pow
  910. .pow_done
  911.     move.l    d2,(a4)
  912.     bra.w    .loop
  913. .or
  914.     bsr.w    Convert
  915.     move.l    (a4),d0
  916.     or.l    d1,d0
  917.     move.l    d0,(a4)
  918.     bra.w    .loop
  919. .and
  920.     bsr.w    Convert
  921.     move.l    (a4),d0
  922.     and.l    d1,d0
  923.     move.l    d0,(a4)
  924.     bra.w    .loop
  925. * routine à mettre au point!
  926. .not
  927.     bsr.w    Convert
  928.     move.l    (a4),d0
  929.     moveq    #-1,d2
  930.     sub.l    d1,d2
  931.     eor.l    d2,d0
  932.     move.l    d0,(a4)
  933.     bra.w    .loop
  934. .rot_left
  935.     cmp.b    #'<',(a0)+
  936.     bne.b    CalcErr
  937.     bsr.w    Convert
  938.     move.l    (a4),d0
  939.     lsl.l    d1,d0
  940.     move.l    d0,(a4)
  941.     bra.w    .loop
  942. .rot_right
  943.     cmp.b    #'>',(a0)+
  944.     bne.b    CalcErr
  945.     bsr.w    Convert
  946.     move.l    (a4),d0
  947.     lsr.l    d1,d0
  948.     move.l    d0,(a4)
  949.     bra.w    .loop
  950.  
  951. CalcErr:
  952.     move.l    (sp)+,a4
  953.     moveq    #-1,d1
  954.     rts
  955.  
  956. result: dc.l    0
  957.  
  958. * Multiplication sur 32 bits (signée ou non)
  959. Mult32: ;d0=Mult32(factor1,factor2)(d0,d1)
  960.     MOVEM.L D2/D3,-(A7)
  961.     MOVE.L    D0,D2
  962.     MOVE.L    D1,D3
  963.     SWAP    D2
  964.     SWAP    D3
  965.     MULU    D1,D2
  966.     MULU    D0,D3
  967.     MULU    D1,D0
  968.     ADD    D3,D2
  969.     SWAP    D2
  970.     CLR    D2
  971.     ADD.L    D2,D0
  972.     MOVEM.L (A7)+,D2/D3
  973.     RTS
  974. * Division sur 32 bits (signée)
  975. Div32:    ;(quotien,remainder)(d0,d1)=DivMod32(dividend,divisor)(d0,d1)
  976. LB_43EE TST.L    D0
  977.     BPL.B    LB_4408
  978.     NEG.L    D0
  979.     TST.L    D1
  980.     BPL.B    LB_4400
  981.     NEG.L    D1
  982.     BSR.B    UDiv32
  983.     NEG.L    D1
  984.     RTS
  985. LB_4400 BSR.B    UDiv32
  986.     NEG.L    D0
  987.     NEG.L    D1
  988.     RTS
  989. LB_4408 TST.L    D1
  990.     BPL.B    UDiv32
  991.     NEG.L    D1
  992.     BSR.B    UDiv32
  993.     NEG.L    D0
  994.     RTS
  995.  
  996. * Division sur 32 bits (non signée)
  997. UDiv32: ;(dividend,divisor)(d0,d1)
  998.     MOVE.L    D3,-(A7)
  999.     CMP.L    #$0000FFFF,D1
  1000.     BHI.B    LB_4440
  1001.     MOVE.L    D1,D3
  1002.     SWAP    D0
  1003.     MOVE    D0,D3
  1004.     BEQ.B    LB_4430
  1005.     DIVU    D1,D3
  1006.     MOVE    D3,D0
  1007. LB_4430 SWAP    D0
  1008.     MOVE    D0,D3
  1009.     DIVU    D1,D3
  1010.     MOVE    D3,D0
  1011.     SWAP    D3
  1012.     MOVE    D3,D1
  1013.     MOVE.L    (A7)+,D3
  1014.     RTS
  1015. LB_4440 MOVE.L    D2,-(A7)
  1016.     MOVE.L    D1,D3
  1017.     MOVE.L    D0,D1
  1018.     CLR    D1
  1019.     SWAP    D1
  1020.     SWAP    D0
  1021.     CLR    D0
  1022.     MOVEQ    #$10,D2
  1023. LB_4450 ADD.L    D0,D0
  1024.     ADDX.L    D1,D1
  1025.     CMP.L    D1,D3
  1026.     BHI.B    LB_445C
  1027.     SUB.L    D3,D1
  1028.     ADDQ    #1,D0
  1029. LB_445C subq    #1,d2
  1030.     bne.s    LB_4450
  1031.     MOVEM.L (A7)+,D2/D3
  1032.     RTS
  1033.  
  1034. *** Changer d'unité de disk <UnitNumber (0-3)>
  1035. * si aucun argument, on affiche le n° du drive courant
  1036. ChangeUnit:
  1037.     addq.l    #2,a0
  1038.     tst.b    (a0)
  1039.     beq.w    .show_current
  1040. ;sauter les espaces en début de chaine, s'il y'en a
  1041.     bsr    spc
  1042. .rdargs
  1043.     bsr    Convert
  1044.  
  1045.     tst.l    d1
  1046.     bmi.s    .badunit
  1047.     moveq    #3,d0
  1048.     cmp.l    d0,d1
  1049.     bhi.s    .badunit
  1050.     move.l    defunit(a5),-(sp)
  1051.     move.l    d1,defunit(a5)
  1052.     lsl.l    #2,d1
  1053.     move.l    unit0(a5,d1.w),d0
  1054.     beq.s    .bad_unit
  1055.     move.l    d0,curunit(a5)
  1056.     addq.l    #4,sp
  1057. .f
  1058.     bra    mainmenu
  1059. .show_current
  1060.     lea    currunit.txt(pc),a0
  1061.     lea    defunit(a5),a1
  1062.     bsr    printf
  1063.     bra.s    .f
  1064. .badargs
  1065.     bsr    BadArgs
  1066.     bra.s    .f
  1067. .bad_unit
  1068.     move.l    (sp)+,defunit(a5)
  1069. .badunit
  1070.     lea    badunit.txt(pc),a0
  1071.     bsr    print
  1072.     bra.s    .f
  1073.  
  1074. *** Jump <addr>
  1075. Jump:
  1076. ;    clr.b    -1(a0,d7.w)
  1077.     addq.l    #1,a0
  1078.     move.b    (a0),d0
  1079.     beq.w    .badargs
  1080.  
  1081.     lea    .inst(pc),a4
  1082.     move    #$4ef9,(a4)    ;instruction JMP
  1083.     lsl    #8,d0
  1084.     addq.l    #1,a0
  1085.     move.b    (a0)+,d0
  1086.     cmp    #'sr',d0        ;'JSR' ?
  1087.     beq.s    .jsr
  1088.     subq.l    #1,a0
  1089.     bra.s    .spc
  1090. .jsr    move    #$4eb9,(a4)    ;instruction JSR
  1091. ;sauter les espaces en début de chaine, s'il y'en a
  1092. .spc    bsr    spc
  1093.  
  1094. .rdargs
  1095.     bsr    Convert
  1096. ;    tst.l    d0
  1097. ;    bne.s    .badargs
  1098.  
  1099. * sauver l'état du système
  1100.     move.l    sp,savesp(a5)
  1101.     lea    $dff000,a0
  1102.     move    2(a0),olddma(a5)
  1103.     move    $1c(a0),oldirq(a5)
  1104.     or.l    #$84008000,olddma(a5)
  1105.     move.l    $6c.w,oldint(a5)
  1106.  
  1107.     lea    .adr(pc),a0
  1108.     move.l    d1,(a0)
  1109.  
  1110. ;    movem.l regs(pc),d0-a7
  1111. .inst    dc.w    $4ef9
  1112. .adr    dc.l    0
  1113. * restituer système
  1114. .restore
  1115.     move    sr,srreg
  1116. ;    movem.l d0-a7,regs
  1117.     move.l    VARS(pc),a5
  1118.     move.l    savesp(a5),sp
  1119.     lea    $dff000,a0
  1120.     move.l    oldint(a5),$6c.w
  1121.     move    #$7fff,$96(a0)
  1122.     move.l    gfxbase(a5),a6
  1123.     move.l    38(a6),$80(a0)
  1124.     clr    $88(a0)
  1125.     move    olddma(a5),$96(a0)
  1126.     move    oldirq(a5),$9a(a0)
  1127.  
  1128.     bra.s    ShowRegs
  1129.  
  1130. .f    bra    mainmenu
  1131. .badargs
  1132.     bsr    BadArgs
  1133.     bra.s    .f
  1134.  
  1135. *** Afficher registres
  1136. ShowRegs:
  1137. ;    move.l    mytask(a5),a0
  1138. ;    move.l    tc_TrapData(a0),d0
  1139. ;    beq.s    .no_trap
  1140. ;    move.l    oldtrap(a5),tc_TrapCode(a0)
  1141.  
  1142. .no_trap
  1143.     lea    regs.txt(pc),a0
  1144.     lea    regs(pc),a1
  1145.     movem.l d0-a6,-(sp)
  1146.     lea    .trap(pc),a5
  1147.     move.l    4.w,a6
  1148.     jsr    Supervisor(a6)
  1149.     move.l    a2,spreg
  1150.     movem.l (sp)+,d0-a6
  1151.     bsr    printf
  1152.  
  1153. .f    bra    mainmenu
  1154. .trap
  1155.     move.l    usp,a2
  1156.     rte
  1157. *** Infos Système
  1158. SysInfo:
  1159.     bsr    CursOff
  1160.  
  1161.     lea    trkbuf(a5),a0
  1162.     move.l    4.w,a6
  1163.     move    AttnFlags(a6),d0
  1164.     moveq    #4,d1
  1165. .cpu040
  1166.     btst    #3,d0
  1167.     bne.s    .cpudone
  1168.     subq    #1,d1
  1169. .cpu030
  1170.     btst    #2,d0
  1171.     bne.s    .cpudone
  1172.     subq    #1,d1
  1173. .cpu020
  1174.     btst    #1,d0
  1175.     bne.s    .cpudone
  1176.     subq    #1,d1
  1177. .cpu010
  1178.     btst    #0,d0
  1179.     bne.s    .cpudone
  1180.     subq    #1,d1
  1181. .cpudone
  1182.     move    d1,(a0)+
  1183.  
  1184.     move    AttnFlags(a6),d0
  1185. .fpu040 btst    #6,d0
  1186.     beq.s    .fpu882
  1187.     lea    fpu040.txt(pc),a1
  1188.     bra.s    .fpudone
  1189. .fpu882 btst    #5,d0
  1190.     beq.s    .fpu881
  1191.     lea    fpu882.txt(pc),a1
  1192.     bra.s    .fpudone
  1193. .fpu881 btst    #4,d0
  1194.     beq.s    .nofpu
  1195.     lea    fpu881.txt(pc),a1
  1196.     bra.s    .fpudone
  1197. .nofpu    lea    nofpu.txt(pc),a1
  1198. .fpudone
  1199.     move.l    a1,(a0)+
  1200.  
  1201.     move.l    $f8000c,(a0)+    ;kickstart version
  1202.     move.l    20(a6),(a0)+    ;exec version
  1203.     move.l    62(a6),(a0)+    ;max loc mem
  1204.     move.l    78(a6),(a0)+    ;max ext mem
  1205.     moveq    #0,d0
  1206.     move.b    530(a6),d0
  1207.     swap    d0
  1208.     move.b    531(a6),d0    ;vblank/power
  1209.     move.l    d0,(a0)+
  1210.     lea    42(a6),a1
  1211.     move.l    (a1)+,(a0)+
  1212.     move.l    (a1)+,(a0)+
  1213.     move.l    (a1)+,(a0)+
  1214.     lea    546(a6),a1
  1215.     move.l    (a1)+,(a0)+
  1216.     move.l    (a1)+,(a0)+
  1217.     move.l    (a1)+,(a0)+
  1218.     move.l    a0,a4
  1219.     moveq    #2!1,d1     ;chip
  1220.     jsr    AvailMem(a6)
  1221.     move.l    d0,(a4)+
  1222.     move.l    #$20000!2!1,d1    ;largest chip
  1223.     jsr    AvailMem(a6)
  1224.     move.l    d0,(a4)+
  1225.     moveq    #4!1,d1     ;fast
  1226.     jsr    AvailMem(a6)
  1227.     move.l    d0,(a4)+
  1228.     move.l    #$20000!4!1,d1    ;largest fast
  1229.     jsr    AvailMem(a6)
  1230.     move.l    d0,(a4)+
  1231.     moveq    #4&2&1,d1    ;total
  1232.     jsr    AvailMem(a6)
  1233.     move.l    d0,(a4)+
  1234.     lea    Main(pc),a0    ;prog start
  1235.     lea    End(pc),a1    ;prog end
  1236.     move.l    a0,(a4)+
  1237.     move.l    a1,(a4)+
  1238.     suba.l    a0,a1        ;prog size
  1239.     move    a1,(a4)+
  1240.     lea    sysinfo.txt(pc),a0
  1241.     lea    trkbuf(a5),a1
  1242.     bsr.w    printf
  1243. .f    bra    mainmenu
  1244.  
  1245. ;Memory dump - 3 possibilités:
  1246. ;  m<return> -> dump de n lignes
  1247. ;  m[start] [end] -> dump de l'adresse start -> end
  1248. ;  m[start] -> dump de l'adresse start -> mouseclick
  1249. NLIN=16
  1250. BYTES_PER_LINE=20
  1251. MemDump:
  1252.     clr.b    dflag(a5)
  1253.     addq.l    #1,a0
  1254.     tst.b    (a0)
  1255.     bne.b    .adr_entered
  1256.     move.l    oldptr(a5),a4
  1257.     moveq    #NLIN-1,d6    ;nbre de lignes à afficher
  1258.     st    dflag(a5)
  1259.     bra.b    .no_end1
  1260. .adr_entered
  1261.     clr.b    -1(a0,d7.w)
  1262. ;sauter les espaces en début de chaine, s'il y'en a
  1263.     bsr    spc
  1264.  
  1265.     move.l    a0,a3
  1266.     lea    .adr(pc),a4
  1267.     moveq    #2-1,d6
  1268. .rdargs
  1269.     move.l    a3,a0
  1270.     bsr    Convert
  1271.     move.l    d1,(a4)+
  1272. .skip    move.b    (a3)+,d0
  1273.     beq.s    .end
  1274.     cmp.b    #$20,d0
  1275.     bne.s    .skip
  1276.     dbf    d6,.rdargs
  1277. .end
  1278.     bsr    CursOff
  1279.     movem.l .adr(pc),d0/d1
  1280.     tst.l    d1
  1281.     beq.s    .no_end
  1282.     move.l    d0,a4
  1283.     move.l    d1,endadr(a5)
  1284.     sub.l    d0,d1
  1285.     cmp    #BYTES_PER_LINE,d1
  1286.     bcs.w    .f
  1287.     bra.b    .dmp
  1288. .no_end
  1289.     move.l    d0,a4        ;start adr
  1290. .no_end1
  1291.     clr.l    endadr(a5)    ;no end adr
  1292. .dmp
  1293.     lea    outbuf(a5),a0
  1294. .bcl
  1295.     move.l    a4,d0
  1296.     move.l    a4,a3
  1297.     bsr    HexConv0
  1298.     move.b    #':',(a0)+
  1299.     move.b    #$20,(a0)+
  1300.  
  1301.     moveq    #(BYTES_PER_LINE/4)-1,d7
  1302. .lop
  1303.     move.l    d7,-(sp)
  1304.     moveq    #3,d7
  1305. .lop1    move.b    (a4)+,d0
  1306.     bsr    HexConvByte
  1307.     dbf    d7,.lop1
  1308.     move.b    #$20,(a0)+
  1309.     move.l    (sp)+,d7
  1310.     dbf    d7,.lop
  1311.     move.b    #$20,(a0)+
  1312.  
  1313.     moveq    #BYTES_PER_LINE-1,d7
  1314. .cop    move.b    (a3)+,(a0)
  1315.  
  1316.     movem.l d1-d2,-(sp)
  1317. .t    move.b    nullchr(pc),d1    ;caract. de remplacement
  1318.     move.b    (a0)+,d2
  1319.     bclr    #7,d2
  1320.     cmp.b    #$20,d2     ;caract. < à $20(=espace)?
  1321.     bcs.b    .no        ;si oui remplacer
  1322.     move.b    d2,d1
  1323.     btst    #7,-1(a0)
  1324.     beq.b    .no
  1325.     bset    #7,d1
  1326. .no    move.b    d1,-1(a0)
  1327.     movem.l (sp)+,d1-d2
  1328.  
  1329.     dbf    d7,.cop
  1330.     move.b    #$a,(a0)+
  1331.     clr.b    (a0)
  1332.  
  1333.     btst    #6,$bfe001
  1334.     beq.b    .f
  1335.  
  1336.     tst.l    endadr(a5)
  1337.     beq.b    .no_end2
  1338.     cmp.l    endadr(a5),a4
  1339.     bhi.b    .f
  1340. .no_end2
  1341.     lea    outbuf(a5),a0
  1342.     bsr    print    ;Line
  1343.  
  1344.     tst.b    dflag(a5)
  1345.     beq.w    .dmp
  1346.     dbf    d6,.dmp
  1347. .f
  1348.     move.l    a4,oldptr(a5)
  1349.     bra    mainmenu
  1350.  
  1351. .adr    dc.l    0,0
  1352.  
  1353. *** ASCII Dump [start] [end]
  1354. AsciiDump:
  1355. NCHR=70
  1356.     clr.b    dflag(a5)
  1357.     addq.l    #1,a0
  1358.     tst.b    (a0)
  1359.     bne.b    .adr_entered
  1360.     move.l    oldptr(a5),a4
  1361.     moveq    #NLIN-1,d6    ;nbre de lignes à afficher
  1362.     st    dflag(a5)
  1363.     bra.b    .no_end1
  1364. .adr_entered
  1365.     clr.b    -1(a0,d7.w)
  1366. ;sauter les espaces en début de chaine, s'il y'en a
  1367.     bsr    spc
  1368.  
  1369.     move.l    a0,a3
  1370.     lea    .adr(pc),a4
  1371.     moveq    #2-1,d6
  1372. .rdargs
  1373.     move.l    a3,a0
  1374.     bsr    Convert
  1375.     move.l    d1,(a4)+
  1376. .skip    move.b    (a3)+,d0
  1377.     beq.s    .end
  1378.     cmp.b    #$20,d0
  1379.     bne.s    .skip
  1380.     dbf    d6,.rdargs
  1381. .end
  1382.     bsr    CursOff
  1383.     movem.l .adr(pc),d0/d1
  1384.     tst.l    d1
  1385.     beq.s    .no_end
  1386.     move.l    d0,a4
  1387.     move.l    d1,endadr(a5)
  1388.     sub.l    d0,d1
  1389.     cmp    #NCHR,d1
  1390.     bcs.b    .f
  1391.     bra.b    .dmp
  1392. .no_end
  1393.     move.l    d0,a4        ;start adr
  1394. .no_end1
  1395.     clr.l    endadr(a5)    ;no end adr
  1396. .dmp
  1397.     moveq    #NCHR,d0
  1398.     move    d0,d1
  1399.     lea    trkbuf(a5),a1
  1400.     subq    #1,d1
  1401. .copmem
  1402.     move.b    (a4)+,(a1)+
  1403.     dbf    d1,.copmem
  1404.  
  1405.     lea    trkbuf(a5),a0
  1406.     bsr.w    Test
  1407. * construire le dump
  1408.     lea    (a0,d0.w),a1
  1409.     clr.b    (a1)
  1410.     move.l    a1,a2
  1411.     moveq    #0,d3
  1412. .bcl0    moveq    #NCHR-1,d1
  1413.     move.l    d3,d7
  1414.     add.l    a4,d7
  1415.     sub    #NCHR,d7
  1416.     bsr.w    Long2Hex
  1417.     move.b    #':',(a1)+
  1418.     move.b    #$20,(a1)+
  1419. .bcl
  1420.     move.b    (a0)+,(a1)+
  1421.     addq    #1,d3
  1422.     dbf    d1,.bcl
  1423.     move.b    #$a,(a1)+
  1424.     clr.b    (a1)
  1425.  
  1426.     btst    #6,$bfe001
  1427.     beq.s    .f
  1428.  
  1429.     tst.l    endadr(a5)
  1430.     beq.b    .no_end2
  1431.     cmp.l    endadr(a5),a4
  1432.     bhi.b    .f
  1433. .no_end2
  1434.     move.l    a2,a0
  1435.     bsr    print    ;Line
  1436.  
  1437.     tst.b    dflag(a5)
  1438.     beq.b    .dmp
  1439.     dbf    d6,.dmp
  1440.  
  1441. .f
  1442.     move.l    a4,oldptr(a5)
  1443.     bra.w    mainmenu
  1444. .adr    dcb.l    2,0
  1445.  
  1446. ;cls    lea    cls.txt(pc),a0
  1447. ;    bra    print
  1448.  
  1449. *** Allouer de la mémoire
  1450. * Alloc   <size>    allouer size octets
  1451. * Alloc #<addr> <size>    allouer size octets à l'adresse <adr> (AllocAbs)
  1452. AllocMemory:
  1453.     addq.l    #1,a0
  1454.     tst.b    (a0)
  1455.     beq.s    .badargs
  1456. ;    clr.b    -1(a0,d7.w)
  1457. ;sauter les espaces en début de chaine, s'il y'en a
  1458.     bsr    spc
  1459.  
  1460.     cmp.b    #'#',(a0)+
  1461.     beq.s    .allocabs
  1462.     subq.l    #1,a0
  1463.  
  1464.     bsr    Convert
  1465.     tst.l    d0
  1466.     bne.s    .badargs
  1467.     move.l    d1,d4
  1468.  
  1469.     move.l    d1,d0
  1470.     moveq    #0,d1
  1471.     move.l    4.w,a6
  1472.     jsr    AllocMem(a6)
  1473.     tst.l    d0
  1474.     beq.s    .failed
  1475. .alloc_ok
  1476.     move.l    d0,-(sp)
  1477.     move.l    d4,-(sp)
  1478.     move.l    sp,a1
  1479.     lea    alloc.txt(pc),a0
  1480.     bsr    printf
  1481.     addq.l    #8,sp
  1482.  
  1483.     bra.s    .f
  1484. .badargs
  1485.     bsr    BadArgs
  1486. .f    bra    mainmenu
  1487.  
  1488. .allocabs
  1489.     bsr    Convert
  1490. ;    tst.l    d0
  1491. ;    bne.s    .badargs
  1492.     move.l    d1,a4
  1493. .spc1    bsr    spc
  1494.     bsr    Convert
  1495.     tst.l    d0
  1496.     bne.s    .badargs
  1497.     move.l    d1,d0
  1498.     move.l    d1,d4
  1499.     move.l    a4,a1
  1500.     move.l    4.w,a6
  1501.     jsr    AllocAbs(a6)
  1502.     tst.l    d0
  1503.     bne.s    .alloc_ok
  1504. .failed
  1505.     lea    allocerr.txt(pc),a0
  1506.     bsr    print
  1507.     bra.s    .f
  1508.  
  1509. *** FreeMemory <addr> <bytesize>
  1510. FreeMemory:
  1511.     addq.l    #1,a0
  1512.     tst.b    (a0)
  1513.     beq.s    .badargs
  1514. ;    clr.b    -1(a0,d7.w)
  1515. ;sauter les espaces en début de chaine, s'il y'en a
  1516. .spc    bsr    spc
  1517.  
  1518.     move.l    a0,a3
  1519.     lea    .adr(pc),a4
  1520.     moveq    #2-1,d6
  1521. .rdargs
  1522.     move.l    a3,a0
  1523.     bsr    Convert
  1524.     move.l    d1,(a4)+
  1525. .skip    move.b    (a3)+,d0
  1526.     beq.s    .end
  1527.     cmp.b    #$20,d0
  1528.     bne.s    .skip
  1529.     dbf    d6,.rdargs
  1530. .end
  1531.     movem.l .adr(pc),d0/a1
  1532.     exg    d0,a1
  1533.     move.l    4.w,a6
  1534.     jsr    FreeMem(a6)
  1535.  
  1536.     bra.s    .f
  1537. .badargs
  1538.     bsr    BadArgs
  1539. .f    bra    mainmenu
  1540. .adr    dcb.l    2,0
  1541.  
  1542. *** Effacer une zone mémoire avec des zéros
  1543. * CL <start> <end>
  1544. ClearMem:
  1545.     addq.l    #2,a0
  1546.     tst.b    (a0)
  1547.     beq.s    .badargs
  1548.     clr.b    -1(a0,d7.w)
  1549. ;sauter les espaces en début de chaine, s'il y'en a
  1550. .spc    bsr    spc
  1551.  
  1552.     move.l    a0,a3
  1553.     lea    .adr(pc),a4
  1554.     moveq    #2-1,d6
  1555. .rdargs
  1556.     move.l    a3,a0
  1557.     bsr    Convert
  1558.     move.l    d1,(a4)+
  1559. .skip    move.b    (a3)+,d0
  1560.     beq.s    .end
  1561.     cmp.b    #$20,d0
  1562.     bne.s    .skip
  1563.     dbf    d6,.rdargs
  1564. .end
  1565.     movem.l .adr(pc),d0-d1    ;StartAdr en d0, EndAdr en d1
  1566.     cmp.l    d0,d1        ;vérifier que StartAdr < EndAdr
  1567.     bcs.s    .badargs
  1568.  
  1569.     lea    clrmem.txt(pc),a0
  1570.     lea    .adr(pc),a1
  1571.     bsr    printf
  1572. ;effacer la zone mémoire
  1573.     movem.l .adr(pc),a0/a1
  1574.     suba.l    a0,a1
  1575.     move.l    a1,d0        ;length
  1576. .clr    clr.b    (a0)+
  1577.     subq.l    #1,d0
  1578.     bne.s    .clr
  1579.  
  1580.     bra.s    .f
  1581. .badargs
  1582.     bsr    BadArgs
  1583. .f    bra    mainmenu
  1584. .adr    dc.l    0,0
  1585.  
  1586. ;Copier une zone mémoire vers une autre
  1587. ;C <start> <end> <dest>
  1588. CopMem:
  1589.     addq.l    #1,a0
  1590.     tst.b    (a0)
  1591.     beq.s    .badargs
  1592. ;    clr.b    (a0,d7.w)
  1593. ;sauter les espaces en début de chaine, s'il y'en a
  1594. .spc    bsr    spc
  1595.  
  1596.     move.l    a0,a3
  1597.     lea    .adr(pc),a4
  1598.     moveq    #3-1,d6
  1599. .rdargs
  1600.     move.l    a3,a0
  1601.     bsr    Convert
  1602.     move.l    d1,(a4)+
  1603. .skip    move.b    (a3)+,d0
  1604.     beq.s    .end
  1605.     cmp.b    #$20,d0
  1606.     bne.s    .skip
  1607.     dbf    d6,.rdargs
  1608. .end
  1609.     movem.l .adr(pc),d0/d1    ;StartAdr en d0, EndAdr en d1
  1610.     cmp.l    d0,d1        ;vérifier que StartAdr < EndAdr
  1611.     bcs.s    .badargs
  1612.  
  1613.     lea    copmem.txt(pc),a0
  1614.     lea    .adr(pc),a1
  1615.     bsr    printf
  1616. ;copier la zone mémoire
  1617.     movem.l .adr(pc),a0/a1/a2
  1618.     suba.l    a0,a1
  1619.     move.l    a1,d0        ;length
  1620.     move.l    a2,a1
  1621.     move.l    4.w,a6
  1622.     jsr    CopyMem(a6)
  1623.  
  1624.     bra.s    .f
  1625. .badargs
  1626.     bsr    BadArgs
  1627. .f    bra    mainmenu
  1628. .adr    dc.l    0,0,0
  1629.  
  1630. *** FIND <start> <end> <data>
  1631. * rechercher une chaine ASCII ou HEX en mémoire
  1632. FindMem:
  1633.     addq.l    #4,a0
  1634.     tst.b    (a0)
  1635.     beq.w    .badargs
  1636. ;    clr.b    -1(a0,d7.w)
  1637. ;sauter les espaces en début de chaine, s'il y'en a
  1638. .spc    bsr    spc
  1639.  
  1640.     move.l    a0,a3
  1641.     lea    .startadr(pc),a4
  1642.     moveq    #2-1,d6
  1643. .rdargs
  1644.     move.l    a3,a0
  1645.     bsr    Convert
  1646.     move.l    d1,(a4)+
  1647. .skip    move.b    (a3)+,d0
  1648.     beq.s    .end
  1649.     cmp.b    #'"',d0
  1650.     beq.s    .end
  1651.     cmp.b    #$20,d0
  1652.     bne.s    .skip
  1653.     dbf    d6,.rdargs
  1654. .end
  1655. .skip1    move.b    (a3)+,d0
  1656.     beq.s    .end1
  1657.     cmp.b    #'"',d0         ;ascii string
  1658.     beq.s    .end1
  1659.     cmp.b    #'$',d0         ;hex string
  1660.     bne.s    .skip1
  1661. .hex
  1662.     move.l    a3,a0
  1663.     bsr    StrLen
  1664.     lsr    #1,d0
  1665.     move.l    d0,d6
  1666.     move.l    d0,d7
  1667.     subq    #1,d7
  1668.     move.l    a3,a0
  1669.     lea    hexbuf(pc),a1
  1670.     move.l    a1,-(sp)
  1671. .hconv
  1672.     moveq    #2,d3
  1673.     bsr    HConv
  1674.     move.b    d1,(a1)+
  1675.     dbf    d7,.hconv
  1676.     clr.b    (a1)
  1677.     move.l    (sp)+,a0
  1678.     bra.s    .start
  1679. .end1
  1680.     move.l    a3,a0        ;adr find-string
  1681.     bsr    StrLen
  1682.     move.l    d0,d6
  1683.     lea    strbuf(pc),a1
  1684.     move.l    a1,-(sp)
  1685.     subq    #1,d0
  1686. .cop    move.b    (a0)+,(a1)+
  1687.     dbf    d0,.cop
  1688.     clr.b    (a1)
  1689.     move.l    (sp)+,a0
  1690. .start
  1691.     lea    .stradr(pc),a1
  1692.     move.l    a0,(a1)
  1693.  
  1694.     move.l    .startadr(pc),a0 ;StartAdr, EndAdr
  1695.     move.l    .endadr(pc),a1
  1696.     suba.l    a0,a1        ;vérifier que StartAdr < EndAdr
  1697.     bmi.s    .badargs
  1698.     move.l    a1,d7
  1699. .find
  1700.     move.l    .stradr(pc),a3
  1701.     move.l    .startadr(pc),a0
  1702.     move.l    d7,d0
  1703. .find_loop
  1704.     btst    #6,$bfe001    ;press leftmousebutton to break
  1705.     beq.s    .f
  1706.  
  1707.     move.l    a3,a4
  1708.     move    d6,d1        ;len find-string
  1709.     subq    #1,d1
  1710. .cmp
  1711.     subq.l    #1,d0
  1712.     bmi.s    .end_reached
  1713.     cmpm.b    (a0)+,(a4)+    ;case insensitive search
  1714.     bne.s    .find_loop
  1715.     dbf    d1,.cmp
  1716.     bra.b    .found
  1717. .end_reached
  1718.     lea    lf.txt(pc),a0
  1719.     bsr    print
  1720.     bra.s    .f        ;fin si pas trouvé
  1721. .found
  1722.     movem.l d0-a6,-(sp)
  1723.     sub.l    d6,a0
  1724.     move.l    a0,-(sp)
  1725.     move.l    sp,a1
  1726.     lea    .adr.txt(pc),a0
  1727.     bsr    printf
  1728.     addq.l    #4,sp
  1729.     movem.l (sp)+,d0-a6
  1730.     bra.s    .find_loop    ;find next occurence
  1731. .badargs
  1732.     bsr    BadArgs
  1733. .f    bra    mainmenu
  1734. .startadr    dc.l    0
  1735. .endadr        dc.l    0
  1736. .stradr dc.l    0
  1737. .adr.txt dc.b '$%08lx ',0
  1738.     even
  1739.  
  1740. *** FILL <start> <end> <data>
  1741. FillMem:
  1742.     addq.l    #4,a0
  1743.     tst.b    (a0)
  1744.     beq.w    .badargs
  1745. ;    clr.b    -1(a0,d7.w)
  1746. ;sauter les espaces en début de chaine, s'il y'en a
  1747. .spc    bsr    spc
  1748.  
  1749.     move.l    a0,a3
  1750.     lea    .startadr(pc),a4
  1751.     moveq    #2-1,d6
  1752. .rdargs
  1753.     move.l    a3,a0
  1754.     bsr    Convert
  1755.     move.l    d1,(a4)+
  1756. .skip    move.b    (a3)+,d0
  1757.     beq.s    .end
  1758.     cmp.b    #'"',d0
  1759.     beq.s    .end
  1760.     cmp.b    #$20,d0
  1761.     bne.s    .skip
  1762.     dbf    d6,.rdargs
  1763. .end
  1764. .skip1    move.b    (a3)+,d0
  1765.     beq.s    .end1
  1766.     cmp.b    #'"',d0         ;ascii string
  1767.     beq.s    .end1
  1768.     cmp.b    #'$',d0         ;hex string
  1769.     bne.s    .skip1
  1770. .hex
  1771.     move.l    a3,a0
  1772.     bsr    StrLen
  1773.     lsr    #1,d0
  1774.     move.l    d0,d6
  1775.     move.l    d0,d7
  1776.     subq    #1,d7
  1777.     move.l    a3,a0
  1778.     lea    hexbuf(pc),a1
  1779.     move.l    a1,-(sp)
  1780. .hconv
  1781.     moveq    #2,d3
  1782.     bsr    HConv
  1783.     move.b    d1,(a1)+
  1784.     dbf    d7,.hconv
  1785.     clr.b    (a1)
  1786.     move.l    (sp)+,a0
  1787.     bra.s    .start
  1788. .end1
  1789.     move.l    a3,a0        ;string addr
  1790.     bsr    StrLen
  1791.     move.l    d0,d6
  1792.     lea    strbuf(pc),a1
  1793.     move.l    a1,-(sp)
  1794.     subq    #1,d0
  1795. .cop    move.b    (a0)+,(a1)+
  1796.     dbf    d0,.cop
  1797.     clr.b    (a1)
  1798.     move.l    (sp)+,a0
  1799. .start
  1800.     lea    .stradr(pc),a1
  1801.     move.l    a0,(a1)
  1802.  
  1803.     move.l    .startadr(pc),a0;StartAdr, EndAdr
  1804.     move.l    .endadr(pc),a1
  1805.     suba.l    a0,a1        ;vérifier que StartAdr < EndAdr
  1806.     bmi.s    .badargs
  1807.     move.l    a1,d7
  1808.  
  1809.     move.l    .stradr(pc),a3
  1810.     move.l    .startadr(pc),a0
  1811.     move.l    d7,d0
  1812. .fill_lop
  1813.     btst    #6,$bfe001
  1814.     beq.s    .f
  1815.  
  1816.     move.l    a3,a4
  1817.     move.l    d6,d1        ;strlen
  1818.     subq    #1,d1
  1819. .fill
  1820.     subq.l    #1,d0
  1821.     bmi.s    .end_reached
  1822.     move.b    (a4)+,(a0)+
  1823.     dbf    d1,.fill
  1824.     bra.s    .fill_lop
  1825. .end_reached
  1826.     bra.s    .f
  1827. .badargs
  1828.     bsr    BadArgs
  1829. .f    bra    mainmenu
  1830. .startadr    dc.l    0
  1831. .endadr        dc.l    0
  1832. .stradr dc.l    0
  1833.  
  1834. *** EditMem <adr>
  1835. EditMem:
  1836.     addq.l    #1,a0
  1837.     tst.b    (a0)
  1838.     beq.w    .badargs
  1839. ;    clr.b    (a0,d7.w)
  1840. ;sauter les espaces en début de chaine, s'il y'en a
  1841. .spc    bsr    spc
  1842.  
  1843.     lea    .adr(pc),a4
  1844.     bsr    Convert
  1845.     move.l    d1,(a4)     ;adr
  1846.  
  1847. .edit
  1848.     lea    adr.txt(pc),a0
  1849.     lea    .adr(pc),a1
  1850.     bsr    printf
  1851.  
  1852.     lea    editbuf(pc),a3
  1853.     clr    comlen(a5)
  1854. .wait
  1855.     move.l    winbase(a5),a0
  1856.     bsr.w    WaitMsg
  1857.     cmp.l    #$400,d6
  1858.     bne.s    .wait
  1859.  
  1860.     btst    #7,d4        ;touche relachée?
  1861.     bne.s    .wait
  1862.     move    d4,d0
  1863.     and    #$60,d0
  1864.     cmp    #$60,d0     ;shift, ctrl, etc..?
  1865.     beq.s    .wait
  1866.  
  1867.     bsr.w    ConvRawKey    ;convertir code rawkey en ascii
  1868.  
  1869.     lea    string(pc),a0
  1870.     move.b    (a0),d0
  1871. ;    cmp.b    #$20,d0
  1872. ;    beq.s    .space
  1873.     cmp.b    #$d,d0        ;cr?
  1874.     beq.s    .return
  1875.     cmp.b    #8,d0        ;backspace?
  1876.     beq.w    .dobackspace
  1877.     cmp.b    #$1b,d0     ;esc?
  1878.     beq.s    .esc
  1879.  
  1880.     move.b    d0,(a3)+
  1881. .space
  1882.     cmp    #editbuflen,comlen(a5)
  1883.     bge.s    .wait
  1884.     addq    #1,comlen(a5)
  1885.     bsr    print
  1886.     bra.s    .wait
  1887. .return
  1888.     clr.b    (a3)
  1889.     lea    lf.txt(pc),a0
  1890.     bsr    print
  1891.     move.l    .adr(pc),a4
  1892.  
  1893.     lea    editbuf(pc),a0
  1894.     cmp.b    #'"',(a0)       ;mode ascii?
  1895.     beq.s    .ascii
  1896.     bsr    StrLen
  1897.     tst.l    d0
  1898.     beq.s    .retry
  1899.     subq.l    #1,d0
  1900.     asr.l    #1,d0
  1901.     move.l    d0,d7
  1902. ;    subq.l    #1,d7
  1903. ;    tst.l    d7
  1904.     blt.s    .retry
  1905. .hconv
  1906.     cmp.b    #$20,(a0)+
  1907.     beq.s    .hconv
  1908.     subq.l    #1,a0
  1909.     moveq    #2,d3
  1910.     bsr    HConv
  1911.     move.b    d1,(a4)+
  1912.     dbf    d7,.hconv
  1913. .fin_ligne
  1914.     lea    .adr(pc),a0
  1915.     move.l    a4,(a0)
  1916.     bra    .edit
  1917. .ascii
  1918.     addq.l    #1,a0
  1919.     bsr    StrLen
  1920.     tst.l    d0
  1921.     beq.s    .retry        ;len=0?
  1922.     subq    #1,d0
  1923. .copmem move.b    (a0)+,(a4)+
  1924.     dbf    d0,.copmem
  1925.     bra.s    .fin_ligne
  1926. .badargs
  1927.     bsr    BadArgs
  1928. .f    bra    mainmenu
  1929. .esc
  1930.     lea    .esc.txt(pc),a0
  1931.     bsr    print
  1932.     bra.s    .f
  1933. .retry
  1934.     lea    .retry.txt(pc),a0
  1935.     bsr    print
  1936.     bra    .edit
  1937. .dobackspace
  1938.     tst    comlen(a5)
  1939.     ble    .wait
  1940.     subq    #1,comlen(a5)
  1941.     cmp.b    #'"',(a3)
  1942.     beq.s    .do_bs
  1943.     subq.l    #1,a3        ;adr-1
  1944. .do_bs    lea    backspace.txt(pc),a0
  1945.     bsr    print
  1946.     bra    .wait
  1947. .adr    dc.l    0
  1948.  
  1949. .retry.txt    dc.b $b
  1950. .esc.txt    dc.b $d,$9b,'K',$d,0
  1951. adr.txt     dc.b '%08lx: ',0
  1952.     even
  1953. *** afficher la liste des modules résidents en mémoire
  1954. ListResModules:
  1955.     move.b    1(a0),d0
  1956.     cmp.b    #'l',d0
  1957.     beq    ListLibs
  1958.     cmp.b    #'d',d0
  1959.     beq    ListDevs
  1960.     cmp.b    #'r',d0
  1961.     beq    ListRes
  1962.     cmp.b    #'t',d0
  1963.     beq    ListTasks
  1964.     cmp.b    #'p',d0
  1965.     beq    ListPorts
  1966.     cmp.b    #'i',d0
  1967.     beq    ListInts
  1968.     cmp.b    #'m',d0
  1969.     beq.s    .resmod
  1970.     cmp.b    #'M',d0
  1971.     beq    ListMem
  1972.     bsr    BadArgs
  1973.     bra.s    .z
  1974. .resmod
  1975.     bsr    CursOff
  1976.     lea    resmods.txt(pc),a0
  1977.     bsr    print
  1978.     move.l    4.w,a6
  1979.     move.l    ResModules(a6),a4
  1980. .c    move.l    (a4)+,d7
  1981.     beq.b    .z
  1982.     btst    #6,$bfe001
  1983.     beq.s    .z
  1984.  
  1985.     lea    -5*4(sp),sp
  1986.     move.l    sp,a1
  1987.     move.l    a1,a2
  1988.     move.l    d7,(a2)+
  1989.     move.l    d7,a0
  1990.     move.b    RT_PRI(a0),d0
  1991.     ext    d0
  1992.     move    d0,(a2)+
  1993.     moveq    #0,d0
  1994.     move.b    RT_VERSION(a0),d0
  1995.     move    d0,(a2)+
  1996.     move.l    RT_NAME(a0),(a2)+
  1997.     lea    .noid.txt(pc),a3
  1998.     tst.l    RT_IDSTRING(a0)
  1999.     beq.s    .id_done
  2000.     move.l    RT_IDSTRING(a0),a3
  2001. .id_done
  2002.     move.l    a3,(a2)+
  2003.     lea    .res.txt(pc),a0
  2004.     bsr    printf
  2005.     lea    5*4(sp),sp
  2006.     bra.b    .c
  2007. .z
  2008.     bra    mainmenu
  2009. .res.txt dc.b '%08lx %-4.4d %-3.3d %-25.25s %s',0
  2010. .noid.txt dc.b $a,0
  2011.     even
  2012. * afficher liste des libraries
  2013. ListLibs:
  2014.     lea    reslibs.txt(pc),a0
  2015.     bsr    print
  2016.     move.l    4.w,a6
  2017.     move.l    LibList(a6),a4
  2018. List_
  2019.     bsr    CursOff
  2020.  
  2021. .list    move.l    a4,d7
  2022.     beq.s    .z
  2023.     tst.l    (a4)
  2024.     beq.s    .z
  2025.     btst    #6,$bfe001
  2026.     beq.s    .z
  2027.  
  2028.     move.l    d7,a0
  2029.     lea    -4*4(sp),sp
  2030.     move.l    sp,a1
  2031.     move.l    a1,a2
  2032.     move.l    d7,(a2)+
  2033.     move    LIB_OPENCNT(a0),(a2)+
  2034.     move    LIB_VERSION(a0),(a2)+
  2035.     move    LIB_REVISION(a0),(a2)+
  2036.     move.l    LN_NAME(a0),(a2)+
  2037.     lea    .txt(pc),a0
  2038.     bsr    printf
  2039.     lea    4*4(sp),sp
  2040.  
  2041.     move.l    (a4),a4     ;next libnode
  2042.     bra.s    .list
  2043. .z
  2044.     bra    mainmenu
  2045. .txt    dc.b    '%08lx %-3d %d.%d',9,'%s',$a,0
  2046.     even
  2047. * afficher liste des devices
  2048. ListDevs:
  2049.     lea    resdevs.txt(pc),a0
  2050.     bsr    print
  2051.     move.l    4.w,a6
  2052.     move.l    DeviceList(a6),a4
  2053.     bra.s    List_
  2054. * afficher liste des resources
  2055. ListRes:
  2056.     lea    resres.txt(pc),a0
  2057.     bsr    print
  2058.     move.l    4.w,a6
  2059.     move.l    ResourceList(a6),a4
  2060.     bra.w    List_
  2061. * afficher PortList
  2062. ListPorts:
  2063.     bsr    CursOff
  2064.     lea    port.txt(pc),a0
  2065.     bsr    print
  2066.     move.l    4.w,a6
  2067.     move.l    PortList(a6),a4
  2068.  
  2069. .list    move.l    a4,d7
  2070.     beq.s    .z
  2071.     tst.l    (a4)
  2072.     beq.s    .z
  2073.     btst    #6,$bfe001
  2074.     beq.s    .z
  2075.  
  2076.     move.l    d7,a0
  2077.     lea    -6*4(sp),sp
  2078.     move.l    sp,a1
  2079.     move.l    a1,a2
  2080.     move.l    d7,(a2)+
  2081.     move.l    LN_NAME(a0),d0
  2082.     bne.s    .put_name
  2083.     lea    .no_name(pc),a3
  2084.     move.l    a3,d0
  2085. .put_name
  2086.     move.l    d0,(a2)+
  2087.  
  2088.     lea    .flag_unkn(pc),a3
  2089.     move.b    MP_FLAGS(a0),d0
  2090.     cmp.b    #2,d0
  2091.     bne.s    .fl_softint
  2092.     lea    .flag_ignore(pc),a3
  2093.     bra.s    .fl_done
  2094. .fl_softint
  2095.     cmp.b    #1,d0
  2096.     bne.s    .fl_signal
  2097.     lea    .flag_softint(pc),a3
  2098.     bra.s    .fl_done
  2099. .fl_signal
  2100.     tst.b    d0
  2101.     bne.s    .fl_done
  2102.     lea    .flag_signal(pc),a3
  2103. .fl_done
  2104.     move.l    a3,(a2)+
  2105.  
  2106.     moveq    #0,d0
  2107.     move.b    MP_SIGBIT(a0),d0
  2108.     move    d0,(a2)+
  2109.  
  2110.     move.l    MP_SIGTASK(a0),a0
  2111.     move.l    LN_NAME(a0),d0
  2112.     bne.s    .put_tname
  2113.     lea    .no_name(pc),a0
  2114.     move.l    a0,d0
  2115. .put_tname
  2116.     move.l    d0,(a2)+
  2117.     lea    .txt(pc),a0
  2118.     bsr    printf
  2119.     lea    6*4(sp),sp
  2120.  
  2121.     move.l    (a4),a4     ;next libnode
  2122.     bra.s    .list
  2123. .z
  2124.     bra    mainmenu
  2125. .txt    dc.b    '%08lx %-20s %-8.8s %-6.6d %s',$a,0
  2126. .no_name    dc.b '-------',0
  2127. .flag_unkn    dc.b '???????',0
  2128. .flag_signal    dc.b 'Signal ',0
  2129. .flag_ignore    dc.b 'Ignore ',0
  2130. .flag_softint    dc.b 'SoftInt',0
  2131.     even
  2132. * afficher InterruptList
  2133. ListInts:
  2134.     bsr    CursOff
  2135.     lea    int.txt(pc),a0
  2136.     bsr    print
  2137.     move.l    4.w,a6
  2138.     move.l    IntrList(a6),a4
  2139.  
  2140. .list    move.l    a4,d7
  2141.     beq.s    .z
  2142.     tst.l    (a4)
  2143.     beq.s    .z
  2144.     btst    #6,$bfe001
  2145.     beq.s    .z
  2146.  
  2147.     move.l    d7,a0
  2148.     lea    -6*4(sp),sp
  2149.     move.l    sp,a1
  2150.     move.l    a1,a2
  2151.     move.l    d7,(a2)+
  2152.     move.l    IS_CODE(a0),(a2)+
  2153.     move.l    IS_DATA(a0),(a2)+
  2154.     move.b    LN_PRI(a0),d0
  2155.     ext    d0
  2156.     move    d0,(a2)+
  2157.     move.l    LN_NAME(a0),d0
  2158.     bne.s    .put_name
  2159.     lea    .no_name(pc),a3
  2160.     move.l    a3,d0
  2161. .put_name
  2162.     move.l    d0,(a2)+
  2163.     lea    .txt(pc),a0
  2164.     bsr    printf
  2165.     lea    6*4(sp),sp
  2166.  
  2167.     move.l    (a4),a4     ;next node
  2168.     tst.l    (a4)
  2169.     bne.s    .list
  2170. .z
  2171.     bra    mainmenu
  2172. .txt    dc.b    '%08lx %08lx %08lx %-4.4d %s',$a,0
  2173. .no_name dc.b '-------',0
  2174.     even
  2175. * afficher TaskList
  2176. ListTasks:
  2177.     bsr    CursOff
  2178.     lea    task.txt(pc),a0
  2179.     bsr    print
  2180.     move.l    4.w,a6
  2181.     jsr    Forbid(a6)
  2182.     move.l    ThisTask(a6),a4
  2183.     bsr.s    .list
  2184.     move.l    TaskWait(a6),a4
  2185.     bsr.s    .list
  2186.     move.l    TaskReady(a6),a4
  2187.     bsr.s    .list
  2188.     jsr    Permit(a6)
  2189.     bra    mainmenu
  2190.  
  2191. .list    move.l    a4,d7
  2192.     beq    .z
  2193.     tst.l    (a4)
  2194.     beq    .z
  2195.     btst    #6,$bfe001
  2196.     beq.w    .z
  2197.  
  2198.     move.l    d7,a0
  2199.     lea    -5*4(sp),sp
  2200.     move.l    sp,a1
  2201.     move.l    a1,a2
  2202.     move.l    d7,(a2)+
  2203.     moveq    #0,d0
  2204.     move.b    LN_TYPE(a0),d0
  2205.     lea    .state_unkn(pc),a3
  2206.     cmp.b    #NT_TASK,d0
  2207.     bne.s    .no_task
  2208.     lea    .type_task(pc),a3
  2209.     bra.s    .type_done
  2210. .no_task
  2211.     cmp.b    #NT_PROCESS,d0
  2212.     bne.s    .type_done
  2213.     lea    .type_proc(pc),a3
  2214. .type_done
  2215.     move.l    a3,(a2)+
  2216.  
  2217.     move.b    tc_State(a0),d0
  2218.     lea    .state_unkn(pc),a3
  2219.     cmp.b    #TS_WAIT,d0
  2220.     bne.s    .no_wait
  2221.     lea    .state_wait(pc),a3
  2222.     bra.s    .state_done
  2223. .no_wait
  2224.     cmp.b    #TS_READY,d0
  2225.     bne.s    .no_ready
  2226.     lea    .state_ready(pc),a3
  2227.     bra.s    .state_done
  2228. .no_ready
  2229.     cmp.b    #TS_RUN,d0
  2230.     bne.s    .no_run
  2231.     lea    .state_run(pc),a3
  2232.     bra.s    .state_done
  2233. .no_run
  2234.     cmp.b    #TS_ADDED,d0
  2235.     bne.s    .no_added
  2236.     lea    .state_added(pc),a3
  2237.     bra.s    .state_done
  2238. .no_added
  2239.     cmp.b    #TS_REMOVED,d0
  2240.     bne.s    .state_done
  2241.     lea    .state_removed(pc),a3
  2242. .state_done
  2243.     move.l    a3,(a2)+
  2244.  
  2245.     move.b    LN_PRI(a0),d0
  2246.     ext    d0
  2247.     move    d0,(a2)+
  2248.  
  2249.     move.l    LN_NAME(a0),(a2)+
  2250.     lea    .txt(pc),a0
  2251.     bsr    printf
  2252.     lea    5*4(sp),sp
  2253.  
  2254.     move.l    (a4),a4     ;next libnode
  2255.     move.l    (a4),d0
  2256.     bne.w    .list
  2257. .z
  2258.     rts
  2259. .txt    dc.b    '%08lx %-7.7s %-7.7s %-4.4d %s',$a,0
  2260. .type_proc    dc.b 'Process',0
  2261. .type_task    dc.b 'Task   ',0
  2262. .state_wait    dc.b 'Waiting',0
  2263. .state_ready    dc.b 'Ready  ',0
  2264. .state_run    dc.b 'Running',0
  2265. .state_added    dc.b 'Added  ',0
  2266. .state_removed    dc.b 'Removed',0
  2267. .state_unkn    dc.b '???????',0
  2268.     even
  2269.  
  2270. * Afficher execbase->MemList
  2271. ListMem:
  2272.     bsr    CursOff
  2273.     lea    mem.txt(pc),a0
  2274.     bsr    print
  2275.     move.l    4.w,a6
  2276.     move.l    MemList(a6),a4
  2277. .lop    tst.l    (a4)
  2278.     beq.s    .end
  2279.     lea    -8*4(sp),sp
  2280.     move.l    sp,a1
  2281.     move.l    a1,a2
  2282.     move.b    LN_TYPE(a4),d0
  2283.     ext    d0
  2284.     move    d0,(a2)+
  2285.     move    MH_ATTRIBUTES(a4),(a2)+
  2286.     move.l    MH_LOWER(a4),(a2)+
  2287.     move.l    MH_UPPER(a4),d0
  2288.     move.l    d0,(a2)+
  2289.     sub.l    MH_LOWER(a4),d0
  2290. ;    divu    #1024,d0
  2291.     lsr.l    #8,d0
  2292.     lsr.l    #2,d0
  2293.     move    d0,(a2)+
  2294.     move.b    LN_PRI(a4),d0
  2295.     ext    d0
  2296.     move    d0,(a2)+
  2297.     move.l    LN_NAME(a4),(a2)+
  2298.     lea    .txt(pc),a0
  2299.     bsr    printf
  2300.     lea    8*4(sp),sp
  2301.     move.l    LN_SUCC(a4),d0
  2302.     move.l    d0,a4
  2303.     tst.l    d0
  2304.     bne.s    .lop
  2305. .end
  2306.     bra    mainmenu
  2307. .txt    dc.b '$%-8.8x $%-4.4x $%08lx $%08lx %-9.9d %-4.4d %s',$a,0
  2308.     even
  2309. *** Calculer le CheckSum d'un BLOCK (bb, bmap, root, udir, fileheader...)
  2310. * b  <addr>    root, udir, fileheader block
  2311. * bb <addr>    Bootblock
  2312. * bm <addr>    Bitmap block
  2313. BlockCheckSum:
  2314.     addq.l    #1,a0
  2315.     move.b    (a0)+,d0
  2316.     beq.s    .badargs
  2317. ;sauter les espaces en début de chaine, s'il y'en a
  2318. .spc    bsr    spc
  2319.  
  2320.     tst.b    1(a0)
  2321.     beq.s    .badargs
  2322.     cmp.b    #'b',d0         ;boot
  2323.     beq.s    .boot
  2324.     cmp.b    #'m',d0         ;bmap
  2325.     beq.s    .bmap
  2326.  
  2327.     bsr    Convert
  2328.     tst.l    d0
  2329.     bne.s    .badargs
  2330.     move.l    d1,a0        ;<addr>
  2331. * calculer checksum (suivant le type de block)
  2332.     moveq    #8,d0        ;blocktype: data
  2333.     cmp.l    (a0),d0
  2334.     beq.s    .data
  2335.  
  2336.     bsr.s    cs_root
  2337. .done
  2338.     move.l    d0,d7
  2339.     lea    checksum.txt(pc),a0
  2340.     movem.l d6-d7,-(sp)
  2341.     move.l    sp,a1
  2342.     bsr    printf
  2343.     addq.l    #8,sp
  2344.     bra.s    .f
  2345.  
  2346. .data
  2347.     bsr.w    cs_data
  2348.     bra.s    .done
  2349. .bmap
  2350. .spc2
  2351.     bsr    spc
  2352.     bsr    Convert
  2353.     tst.l    d0
  2354.     bne.s    .badargs
  2355.     move.l    d1,a0
  2356.     bsr.s    cs_bmap
  2357.     bra.s    .done
  2358. .boot
  2359. .spc3
  2360.     bsr    spc
  2361.     bsr    Convert
  2362.     tst.l    d0
  2363.     bne.s    .badargs
  2364.     move.l    d1,a0
  2365.     bsr.s    cs_boot
  2366.     bra.s    .done
  2367. .badargs
  2368.     bsr    BadArgs
  2369. .f    bra    mainmenu
  2370.  
  2371. * calc. Bootblock CheckSum
  2372. cs_boot:
  2373.     move.l    4(a0),d6
  2374.     clr.l    4(a0)
  2375.     move.l    a0,-(sp)
  2376.     moveq    #0,d0
  2377.     move    #$ff,d1
  2378. .bcl    add.l    (a0)+,d0
  2379.     bcc.s    .do
  2380.     addq.l    #1,d0
  2381. .do    dbf    d1,.bcl
  2382.     not.l    d0
  2383.     move.l    (sp)+,a0
  2384.     move.l    d0,4(a0)
  2385.     rts
  2386. * routine valable pour root, udir, list, file.
  2387. cs_root:
  2388.     move.l    20(a0),d6    ;ancien checksum
  2389.     clr.l    20(a0)        ;effacer ancien
  2390.     move.l    a0,-(sp)
  2391.     moveq    #$7f,d1     ;nbre de mots
  2392.     moveq    #0,d0
  2393. .bcl    add.l    (a0)+,d0
  2394.     dbf    d1,.bcl
  2395.     subq.l    #1,d0
  2396.     not.l    d0
  2397.     move.l    (sp)+,a0
  2398.     move.l    d0,20(a0)    ;nveau csum
  2399.     rts
  2400. cs_bmap:
  2401.     move.l    (a0),d6     ;ancien checkum
  2402.     clr.l    (a0)        ;effacer ancien
  2403.     move.l    a0,-(sp)
  2404.     moveq    #$7f,d1     ;nbre de mots
  2405.     moveq    #0,d0
  2406. .bcl    add.l    (a0)+,d0
  2407.     dbf    d1,.bcl
  2408.     not.l    d0
  2409.     addq.l    #1,d0
  2410.     move.l    (sp)+,a0
  2411.     move.l    d0,(a0)     ;nveau csum
  2412.     rts
  2413. cs_data
  2414.     move.l    20(a0),d6    ;ancien checksum
  2415.     clr.l    20(a0)        ;effacer ancien
  2416.     move.l    a0,-(sp)
  2417.     moveq    #$7f,d1     ;nbre de mots
  2418.     moveq    #0,d0
  2419. .bcl    add.l    (a0)+,d0
  2420.     dbf    d1,.bcl
  2421.     not.l    d0
  2422.     addq.l    #1,d0
  2423.     move.l    (sp)+,a0
  2424.     move.l    d0,20(a0)    ;nveau csum
  2425.     rts
  2426.  
  2427. *** Install disk  [unité] [FFS]
  2428. InstallDisk:
  2429.     addq.l    #4,a0
  2430.  
  2431.     move.l    defunit(a5),d6    ;unité par défaut
  2432.     moveq    #0,d7        ;flag: 0=OFS, 1=FFS
  2433.  
  2434.     tst.b    (a0)
  2435.     beq.s    .no_opts
  2436. ;sauter les espaces en début de chaine, s'il y'en a
  2437. .spc    bsr    spc
  2438.  
  2439.     bsr    Convert
  2440.     tst.l    d1
  2441.     bmi.w    .badunit
  2442.     moveq    #3,d0
  2443.     cmp.l    d0,d1
  2444.     bhi.w    .badunit
  2445.     lsl.l    #2,d1
  2446.     move.l    d1,d6        ;unit en d6
  2447.  
  2448. .spc1
  2449.     bsr    spc
  2450.     moveq    #0,d0
  2451.     move.b    (a0)+,d0
  2452.     lsl.l    #8,d0
  2453.     move.b    (a0)+,d0
  2454.     lsl.l    #8,d0
  2455.     move.b    (a0)+,d0
  2456.     lsl.l    #8,d0
  2457.     clr.b    d0
  2458.     and.l    #$dfdfdf00,d0
  2459.     cmp.l    #$46465300,d0    ;'FFS' ?
  2460.     bne.s    .ofs
  2461.     moveq    #1,d7
  2462. .ofs
  2463.  
  2464. .no_opts
  2465.     lea    bootblock.data(pc),a0
  2466.     move.b    d7,3(a0)
  2467.     lea    trkbuf(a5),a1
  2468.     moveq    #bootblock.size-1,d0
  2469. .cop    move.b    (a0)+,(a1)+
  2470.     dbf    d0,.cop
  2471.  
  2472.     lea    trkbuf(a5),a0
  2473.     move.l    d6,-(sp)
  2474.     bsr    cs_boot     ;calculer checksum
  2475.     move.l    (sp)+,d6
  2476.  
  2477.     move.l    unit0(a5,d6.w),a1
  2478.     move.l    a1,d7
  2479.     beq.s    .badunit
  2480.  
  2481.     move    #3,28(a1)    ;TD_WRITE
  2482.     move.l    a0,40(a1)    ;io_data: adr
  2483.     clr.l    44(a1)        ;io_offset
  2484.     move.l    #$400,36(a1)    ;io_length
  2485.     move.l    4.w,a6
  2486.     jsr    DoIO(a6)
  2487.     tst.l    d0
  2488.     beq.s    .no_err
  2489.     lea    diskerr.txt(pc),a0
  2490.     bsr    print
  2491. .no_err
  2492.     move.l    d7,a1
  2493.     move    #4,28(a1)    ;TD_UPDATE
  2494.     jsr    DoIO(a6)
  2495.  
  2496.     bsr    MotorOff
  2497. .f
  2498.     bra    mainmenu
  2499. .badargs
  2500.     bsr    BadArgs
  2501.     bra.s    .f
  2502. .badunit
  2503.     lea    badunit.txt(pc),a0
  2504.     bsr    print
  2505.     bra.s    .f
  2506.  
  2507.  
  2508. *** Read Diskblocks <adr> <offset> <length>
  2509. ReadBlocks:
  2510.     clr.b    -1(a0,d7.w)
  2511.     addq.l    #1,a0
  2512.     tst.b    (a0)
  2513.     beq.w    .badargs
  2514. ;sauter les espaces en début de chaine, s'il y'en a
  2515. .spc    bsr    spc
  2516.  
  2517.     move.l    a0,a3
  2518.     lea    .adr(pc),a4
  2519.     moveq    #4-1,d6
  2520. .rdargs
  2521.     move.l    a3,a0
  2522.     bsr    Convert
  2523.     move.l    d1,(a4)+
  2524. .skip    move.b    (a3)+,d0
  2525.     beq.s    .end
  2526.     cmp.b    #$20,d0
  2527.     bne.s    .skip
  2528.     dbf    d6,.rdargs
  2529. .end
  2530. * lire les blocks
  2531.     lea    readblk.txt(pc),a0
  2532.     lea    .adr(pc),a1
  2533.     move.l    defunit(a5),3*4(a1)
  2534.     bsr    printf
  2535.  
  2536.     move.l    curunit(a5),a1
  2537.     move.l    a1,d7
  2538.  
  2539.     move    #2,28(a1)    ;TD_READ
  2540.     lea    .adr(pc),a0
  2541.     move.l    (a0),oldptr(a5) ;adresse pour le dump
  2542.     move.l    (a0)+,40(a1)    ;io_data: adr
  2543.     move.l    (a0)+,d0    ;<offset>
  2544.     moveq    #9,d1
  2545.     lsl.l    d1,d0
  2546.     move.l    d0,44(a1)    ;io_offset
  2547.     move.l    (a0)+,d0    ;<len>
  2548.     lsl.l    d1,d0
  2549.     move.l    d0,36(a1)    ;io_length
  2550.     move.l    4.w,a6
  2551.     jsr    DoIO(a6)
  2552.     tst.l    d0
  2553.     beq.s    .no_err
  2554.     lea    diskerr.txt(pc),a0
  2555.     bsr    print
  2556. .no_err
  2557.     bsr    MotorOff
  2558.     bra.s    .nodev
  2559. .abort
  2560.     lea    abort.txt(pc),a0
  2561.     bsr    print
  2562. .nodev
  2563.     bra.s    .f
  2564. .badargs
  2565.     bsr.w    BadArgs
  2566. .f
  2567.     bra    mainmenu
  2568.  
  2569. .adr    dcb.l    5,0
  2570.  
  2571. *** Write Diskblocks <adr> <offset> <length>
  2572. WriteBlocks:
  2573.     clr.b    -1(a0,d7.w)
  2574.     addq.l    #1,a0
  2575.     tst.b    (a0)
  2576.     beq.w    .badargs
  2577. ;sauter les espaces en début de chaine, s'il y'en a
  2578. .spc    bsr    spc
  2579.  
  2580.     move.l    a0,a3
  2581.     lea    .adr(pc),a4
  2582.     moveq    #4-1,d6
  2583. .rdargs
  2584.     move.l    a3,a0
  2585.     bsr    Convert
  2586.     move.l    d1,(a4)+
  2587. .skip    move.b    (a3)+,d0
  2588.     beq.s    .end
  2589.     cmp.b    #$20,d0
  2590.     bne.s    .skip
  2591.     dbf    d6,.rdargs
  2592. .end
  2593. * lire les blocks
  2594.     lea    readblk.txt(pc),a0
  2595.     lea    .adr(pc),a1
  2596.     move.l    defunit(a5),3*4(a1)
  2597.     bsr    printf
  2598.  
  2599.     move.l    curunit(a5),a1
  2600.     move.l    a1,d7
  2601.  
  2602.     move    #3,28(a1)    ;TD_WRITE
  2603.     lea    .adr(pc),a0
  2604.     move.l    (a0)+,40(a1)    ;io_data: adr
  2605.     move.l    (a0)+,d0    ;<offset>
  2606.     moveq    #9,d1
  2607.     lsl.l    d1,d0
  2608.     move.l    d0,44(a1)    ;io_offset
  2609.     move.l    (a0)+,d0    ;<len>
  2610.     lsl.l    d1,d0
  2611.     move.l    d0,36(a1)    ;io_length
  2612.     move.l    4.w,a6
  2613.     jsr    DoIO(a6)
  2614.     tst.l    d0
  2615.     beq.s    .no_err
  2616.     lea    diskerr.txt(pc),a0
  2617.     bsr    print
  2618. .no_err
  2619.     move.l    d7,a1
  2620.     move    #4,28(a1)    ;TD_UPDATE
  2621.     jsr    DoIO(a6)
  2622.  
  2623.     bsr    MotorOff
  2624.     bra.s    .nodev
  2625. .abort
  2626.     lea    abort.txt(pc),a0
  2627.     bsr    print
  2628. .nodev
  2629.     bra.s    .f
  2630. .badargs
  2631.     bsr.w    BadArgs
  2632. .f
  2633.     bra    mainmenu
  2634.  
  2635. .adr    dcb.l    5,0
  2636.  
  2637.  
  2638. **** routines Trackdisk
  2639. *** Ouvrir une unité de disk
  2640. * <-- d0: n° unité (0,..,4)
  2641. * --> d0: Structure 'Unit', ou 0 si erreur
  2642. OpenUnit:
  2643.     move.l    d0,d7
  2644. * on alloue d'abord une structure 'custom': la structure 'Unit'
  2645. * qui regroupe l'IORequest et le MsgPort
  2646.     moveq    #34+56,d0
  2647.     move.l    #$10001,d1
  2648.     move.l    4.w,a6
  2649.     jsr    AllocMem(a6)
  2650.     move.l    d0,d6
  2651.     beq.b    .err
  2652. * initialiser MsgPort
  2653.     move.l    d6,a1
  2654.     lea    56(a1),a1    ;ptr sur MsgPort
  2655.     move.l    a1,-(sp)
  2656.     move.l    mytask(a5),$10(a1)
  2657.     jsr    AddPort(a6)    ;trackdisk message port
  2658.     tst.l    d0
  2659.     beq.b    .free
  2660. * ouvrir device
  2661.     move.l    d6,a1
  2662.     move.l    (sp)+,14(a1)    ;msgport
  2663.     move.l    d7,d0        ;unit #
  2664.     moveq    #1,d1        ;flags: ALLOW_NON_3_5
  2665.     lea    trackname(pc),a0
  2666.     jsr    OpenDevice(a6)
  2667.     tst.l    d0        ;0=no err
  2668.     bne.b    .remport
  2669.     move.l    d6,d0        ;En retour: Unit (0=err)
  2670.     rts
  2671. .remport
  2672.     move.l    d6,a1
  2673.     lea    56(a1),a1
  2674.     jsr    RemPort(a6)
  2675. .free
  2676.     move.l    d6,a1
  2677.     moveq    #34+56,d0
  2678.     jsr    FreeMem(a6)
  2679. .err    moveq    #0,d0
  2680.     rts
  2681.  
  2682. * <-- a0: struct 'Unit' de l'unité à fermer
  2683. CloseUnit:
  2684.     move.l    a0,d6
  2685.     beq.b    .f
  2686.     move.l    a0,-(sp)
  2687.     move.l    14(a0),a1
  2688.     jsr    RemPort(a6)    ;supprimer le port
  2689.     move.l    (sp)+,a1
  2690.     jsr    CloseDevice(a6)
  2691.     move.l    d6,a1
  2692.     moveq    #34+56,d0
  2693.     jmp    FreeMem(a6)    ;libérer struct 'unit'
  2694. .f    rts
  2695.  
  2696. * éteindre le moteur du drive courant
  2697. MotorOff:
  2698.     movem.l d0-a6,-(sp)
  2699.     move.l    curunit(a5),a1
  2700.     move    #9,28(a1)
  2701.     clr.l    36(a1)
  2702.     move.l    4.w,a6
  2703.     jsr    DoIO(a6)
  2704.     movem.l (sp)+,d0-a6
  2705.     rts
  2706.  
  2707. BadArgs:
  2708.     move.l    a0,-(sp)
  2709.     lea    badargs.txt(pc),a0
  2710.     bsr    print
  2711.     move.l    (sp)+,a0
  2712.     rts
  2713.  
  2714.  
  2715. *** Désinstaller RESET-TOOL
  2716. UnInstall:
  2717.     lea    uninstall.txt(pc),a0
  2718.     bsr    print
  2719.     move.l    myresptr(pc),a0
  2720.     clr    (a0)        ;clear RTC_MATCHWORD
  2721.                 ;so that I won't be recognized at next reboot
  2722.                 ;but the memory I use isn't freed though
  2723.  
  2724. *** Effectuer un reboot de la machine
  2725. reboot:
  2726.     IFEQ    DBUG
  2727.  
  2728. MAGIC_ROMEND        EQU $01000000   ;End of Kickstart ROM
  2729. MAGIC_SIZEOFFSET    EQU -$14        ;Offset from end of ROM to Kickstart size
  2730.     move.l    4.w,a6
  2731.     cmp    #36,LIB_VERSION(a6)
  2732.     blt.s    .old_exec
  2733.     jmp    ColdReboot(a6)     ;Let Exec do it...
  2734. * manually reset the Amiga
  2735. .old_exec
  2736.     lea    .GoAway(pc),a5    ;address of code to execute
  2737.     jsr    Supervisor(a6)    ;trap to code at (a5)...
  2738.     ;NOTE: Control flow never returns to here
  2739. * MagicResetCode --- DO NOT CHANGE
  2740.     CNOP    0,4            ;IMPORTANT! Longword align!
  2741. .GoAway    lea    MAGIC_ROMEND,a0     ;(end of ROM)
  2742.     sub.l    MAGIC_SIZEOFFSET(a0),a0    ;(end of ROM)-(ROM size)=PC
  2743.     move.l    4(a0),a0        ;Get Initial Program Counter
  2744.     subq.l    #2,a0            ;now points to second RESET
  2745.     reset                ;first RESET instruction
  2746.     jmp    (a0)            ;CPU Prefetch executes this
  2747.     ;NOTE: the RESET and JMP instructions must share a longword!
  2748.  
  2749.     ENDC
  2750.     bra    mainmenu
  2751.  
  2752. *** Desass [start] [end]
  2753. DIS_LINES=16
  2754. Dis:
  2755. ;    clr.b    -1(a0,d7.w)
  2756.     addq.l    #1,a0
  2757.     tst.b    (a0)        ;pas d'arguments?
  2758.     beq.s    .lastadr
  2759. ;sauter les espaces en début de chaine, s'il y'en a
  2760. .spc    bsr    spc
  2761.  
  2762.     move.l    a0,a3
  2763.     lea    .adr(pc),a4
  2764.     clr.l    (a4)        ;start addr=0
  2765.     clr.l    4(a4)        ;end addr=0
  2766.     moveq    #2-1,d6
  2767. .rdargs
  2768.     move.l    a3,a0
  2769.     bsr    Convert
  2770.     move.l    d1,(a4)+
  2771. .skip    move.b    (a3)+,d0
  2772.     beq.s    .end
  2773.     cmp.b    #$20,d0
  2774.     bne.s    .skip
  2775.     dbf    d6,.rdargs
  2776. .end
  2777.     bsr    CursOff
  2778.  
  2779.     movem.l .adr(pc),d0-d1
  2780.     tst.l    d1        ;pas d'addr de fin?
  2781.     beq.s    .dis        ;alors on veut un certain nombre de lignes
  2782.     sub.l    d0,d1
  2783.     bmi.s    .badargs
  2784. .dis    move.l    .adr(pc),a0
  2785.     moveq    #DIS_LINES-1,d7
  2786. .bcl
  2787.     btst    #6,$bfe001
  2788.     beq.s    .f
  2789.     lea    strbuf(pc),a1
  2790.     bsr.s    Desass
  2791.     lea    strbuf(pc),a0
  2792.     bsr    print
  2793.     move.l    d0,a0
  2794.  
  2795.     move.l    .adr+4(pc),d1
  2796.     bne.s    .until_end
  2797.     dbf    d7,.bcl
  2798.     bra.s    .f
  2799. .until_end
  2800.     cmp.l    d0,d1
  2801.     bhi.s    .bcl
  2802.  
  2803. .f
  2804.     move.l    d0,lastdis(a5)    ;sauver adresse
  2805. .f1    bra    mainmenu
  2806. .badargs
  2807.     bsr    BadArgs
  2808.     bra.s    .f1
  2809. .lastadr
  2810.     lea    .adr(pc),a4
  2811.     move.l    lastdis(a5),(a4)
  2812.     clr.l    4(a4)
  2813.     bra.s    .end
  2814.  
  2815. .adr    dc.l    0,0
  2816.  
  2817. *** Désassembleur MC68000
  2818. * rippé dans 'ROMCRACK' de SCA
  2819. * amélioré par Frédéric Bassaler
  2820. *
  2821. * cette routine désassemble une ligne de code
  2822. * paramètres d'entrée:
  2823. * a0: src
  2824. * a1: dest
  2825. * en sortie:
  2826. * d0: adresse instruction suivante
  2827. da_LF=$a
  2828. Desass:
  2829.     movem.l d2-d7/a2-a4,-(sp)
  2830.     move.l    a1,a3
  2831.     move.l    a0,d0
  2832.     bclr    #0,d0        ;adresse paire
  2833.     move.l    d0,a4
  2834.     move.l    d0,-(sp)
  2835.     moveq    #7,d1
  2836.     bsr.w    ConvHex2    ;convertir adr de désass.
  2837.     move.l    (sp)+,d0
  2838.     move.b    #':',(a3)+
  2839.     move.b    #9,(a3)+
  2840.     lea    passflag(pc),a0
  2841.     clr.b    (a0)
  2842.     move.l    a0,-(sp)
  2843.     bsr.b    desass_instruction
  2844.     move.l    (sp)+,a0
  2845.     tst.b    (a0)
  2846.     bne.s    .no_second_pass
  2847.     move.b    #9,(a3)+    ;tab
  2848.     bsr.w    desass_instruction2
  2849. .no_second_pass
  2850.     move.b    #da_LF,(a3)+    ;lf
  2851.     clr.b    (a3)
  2852.     move.l    a4,d0
  2853.     move.b    d7,d1
  2854.     movem.l (sp)+,d2-d7/a2-a4
  2855.     rts
  2856.  
  2857. ;détermine l'instruction
  2858. desass_instruction:
  2859.     move    (a4)+,d5
  2860.  
  2861. ;    move    d5,d0
  2862. ;    moveq    #3,d1
  2863. ;    bsr.w    ConvHex2    ;hexdump de l'opcode
  2864. ;    move.b    #9,(a3)+
  2865.  
  2866.     move    d5,d0
  2867.     and    #$f000,d0
  2868.     cmp    #$a000,d0
  2869.     beq.w    line_a
  2870.     cmp    #$f000,d0
  2871.     beq.w    line_f
  2872.  
  2873.     move.b    #$c0,d4
  2874.     and.b    d5,d4
  2875.     lea    instruction_table(pc),a0
  2876.     moveq    #0,d2
  2877. next_op:
  2878.     move    d5,d1
  2879.     and    (a0)+,d1
  2880.     cmp    (a0)+,d1
  2881.     beq.s    opcode_found
  2882.     addq    #1,d2
  2883.     addq    #2,a0
  2884.     bra.s    next_op
  2885. opcode_found:
  2886.     move    (a0),d6
  2887.     bclr    #14,d6
  2888.     sne    d7
  2889.     lea    instructions.txt(pc),a0
  2890. lop
  2891.     move.l    a3,a1
  2892. .lop0
  2893.     move.b    (a0)+,d0
  2894.     cmp.b    #'*',d0
  2895.     beq.s    opcode_inconnu
  2896.     cmp.b    #'+',d0
  2897.     beq.s    point
  2898.     move.b    d0,(a1)+
  2899.     cmp.b    #'Z',d0
  2900.     bcs.s    .lop0
  2901.     bclr    #5,-1(a1)
  2902.     bra.s    lop1
  2903.  
  2904. point    move.b    #'.',(a1)+
  2905.  
  2906. lop1    dbf    d2,lop
  2907.     move.l    a1,a3
  2908.     lea    -4(a3),a0
  2909.     cmp.b    #'@',(a0)
  2910.     beq.s    get_condition_code
  2911.     addq.l    #2,a0
  2912.     cmp.b    #'@',(a0)
  2913.     bne.s    get_instruction
  2914. get_condition_code:
  2915.     move    d5,d0
  2916.     lsr    #7,d0
  2917.     and    #30,d0
  2918.     lea    condition_codes.txt(pc,d0.w),a2
  2919. ;    add    d0,a2
  2920.     move.b    (a2)+,(a0)+    ;copier le code de condition
  2921.     move.b    (a2),(a0)
  2922. get_instruction:
  2923.     move    d5,d0
  2924.     and    #$f138,d0
  2925.     cmp    #$0108,d0    ;type movep
  2926.     bne.w    no_movep
  2927.     or    #$0020,d5
  2928.     or.b    #$80,d4
  2929.     bra.w    lbc001a68
  2930. opcode_inconnu:
  2931.     move.l    a1,a3
  2932.     lea    dc.txt(pc),a0
  2933.     bsr.w    cop_str
  2934.     move    d5,d0
  2935.     bsr.s    sort_hex16
  2936.     move.b    #9,(a3)+
  2937.     move.b    #9,(a3)+
  2938.     move    d5,d0
  2939.     move.b    #';',(a3)+
  2940.     move.b    #'"',(a3)+
  2941.     bsr.s    sort_ascii
  2942.     move.b    #'"',(a3)+
  2943.     rts
  2944. sort_ascii:
  2945.     moveq    #1,d1
  2946. .put
  2947.     ror    #8,d0
  2948.     cmp.b    #$20,d0
  2949.     bcs.s    .null
  2950.     cmp.b    #$80,d0
  2951.     bcs.s    .put1
  2952. .null    moveq    #'.',d0
  2953. .put1    move.b    d0,(a3)+
  2954.     dbf    d1,.put
  2955.     rts
  2956. condition_codes.txt:dc.b 'T F HILSCCCSNEEQVCVSPLMIGELTGTLE'
  2957.     even
  2958. line_a:
  2959.     moveq    #'A',d1
  2960. line_:
  2961.     lea    line.txt(pc),a0
  2962.     bsr.w    cop_str
  2963.     move.b    d1,(a3)+
  2964.     move.b    #9,(a3)+
  2965.     move    d5,d0
  2966.     and    #$0fff,d0
  2967.     moveq    #0,d7
  2968. sort_hex16:
  2969.     bsr.w    ConvHex16
  2970.     lea    passflag(pc),a0
  2971.     st    (a0)
  2972.     rts
  2973. line_f:
  2974.     moveq    #'F',d1
  2975.     bra.s    line_
  2976. line.txt:dc.b 'LINE_',0
  2977. dc.txt: dc.b 'DC.W',9,0
  2978. passflag:dc.b    0
  2979.     even
  2980. no_movep:
  2981.     move    #$0200,d0
  2982.     and    d6,d0
  2983.     beq.s    lbc001a6e
  2984. lbc001a68
  2985.     sub.b    #$40,d4
  2986.     bra.s    lbc001a76
  2987.  
  2988. lbc001a6e
  2989.     moveq    #1,d0
  2990.     and    d6,d0
  2991.     beq.s    ret0
  2992. lbc001a76
  2993.     move.b    d4,d0
  2994.     move.b    #'L',(a3)
  2995.     cmp.b    #$80,d0
  2996.     beq.s    lbc001a94
  2997.     move.b    #'W',(a3)
  2998.     cmp.b    #$40,d0
  2999.     beq.s    lbc001a94
  3000.     move.b    #'B',(a3)
  3001.     move.b    #$c0,d0
  3002. lbc001a94
  3003.     or.b    d0,d6
  3004.     addq    #1,a3
  3005. ret0:    rts
  3006.  
  3007. ;après avoir déterminé l'instruction,
  3008. ;il faut la décoder
  3009. desass_instruction2:
  3010.     move    d5,d0
  3011.     and    #$fff8,d0
  3012.     cmp    #$4e70,d0    ;nop, rte, rts...
  3013.     bne.s    des_ins
  3014.     rts
  3015. des_ins:
  3016.     lea    _usp.txt(pc),a0
  3017.     move    d5,d0
  3018.     and    #$fff0,d0
  3019.     cmp    #$4e60,d0    ;move ax,usp
  3020.     bne.s    no_move_ax_usp
  3021.     move    d5,d0
  3022.     and    #$ffc7,d5
  3023.     moveq    #8,d1
  3024.     or    d1,d5
  3025.     and    d1,d0
  3026.     bne.s    move_sr_dx
  3027. move_dx_sr:
  3028.     move.l    a0,-(sp)
  3029.     bsr.w    lbc001baa
  3030.     move.b    #',',(a3)+
  3031.     move.l    (sp)+,a0
  3032.     bra.w    cop_str
  3033.  
  3034. move_sr_dx:
  3035.     bsr.w    cop_str
  3036.     bra.w    lbc001c34
  3037.  
  3038. no_move_ax_usp:
  3039.     cmp    #$4e40,d0    ;instruction trap
  3040.     bne.s    no_trap
  3041.     move.b    #'#',(a3)+
  3042.     move    d5,d0
  3043.     and    #$0f,d0
  3044.     bra.w    ConvByte
  3045.  
  3046. no_trap:
  3047.     lea    _sr.txt(pc),a0
  3048.     and    #$ffc0,d0
  3049.     cmp    #$40c0,d0    ;move sr,dx
  3050.     beq.s    move_sr_dx
  3051.     cmp    #$46c0,d0    ;move dx,sr
  3052.     beq.s    move_dx_sr
  3053.     lea    _ccr.txt(pc),a0
  3054.     cmp    #$44c0,d0    ;move dx,ccr
  3055.     beq.s    move_dx_sr
  3056.     move    d6,d0
  3057.     and    #$30,d0
  3058.     beq.s    lbc001b40
  3059.     cmp    #$10,d0
  3060.     beq.s    lbc001b40
  3061.     bsr.w    lbc001baa
  3062.     move.b    #',',(a3)+
  3063.     move    d6,d1
  3064.     moveq    #1,d0
  3065.     and    #$30,d1
  3066.     cmp    #$30,d1
  3067.     beq.s    lbc001b38
  3068.     moveq    #0,d0
  3069. lbc001b38
  3070.     bsr.w    lbc001e92
  3071.     bra.w    lbc001d32
  3072.  
  3073. lbc001b40
  3074.     move    d5,d0
  3075.     and    #$f0f8,d0
  3076.     cmp    #$50c8,d0    ;dbxx dx,label
  3077.     bne.s    no_dbcc
  3078.     and    #7,d5
  3079.     or    #$15c0,d5
  3080. no_dbcc:
  3081.     move    d6,d0
  3082.     and    #$0400,d0
  3083.     beq.s    lbc001b64
  3084.     and    #$0e07,d5
  3085.     or    #$10d8,d5
  3086. lbc001b64
  3087.     move    d6,d0
  3088.     and    #$1000,d0
  3089.     beq.s    lbc001b80
  3090.     move    d5,d1
  3091.     and    #$0e07,d5
  3092.     or    #$1000,d5
  3093.     and    #8,d1
  3094.     beq.s    lbc001b80
  3095.     or    #$0120,d5
  3096. lbc001b80
  3097.     move    d5,d0
  3098.     and    #$c000,d0
  3099.     bne.s    lbc001baa
  3100.     move    d5,d0
  3101.     and    #$3000,d0
  3102.     beq.s    lbc001baa
  3103.     bsr.b    lbc001baa
  3104.     move.b    #',',(a3)+
  3105.     bsr.w    lbc001e92
  3106.     move    d5,d0
  3107.     and    #$01c0,d0
  3108.     lsr    #3,d0
  3109.     and    #$f000,d5
  3110.     or    d1,d5
  3111.     or    d0,d5
  3112. lbc001baa
  3113.     move    d5,d0
  3114.     and    #$ff00,d0
  3115.     cmp    #$0800,d0    ;btst
  3116.     bne.s    no_btst
  3117.     move.b    #'#',(a3)+
  3118.     move    (a4)+,d1    ;# de bit
  3119.     and    #31,d1        ;ne peut dépasser 31 !
  3120.     bra.s    conv_byte
  3121.  
  3122. no_btst:
  3123.     move    d6,d0
  3124.     and    #$0100,d0
  3125.     beq.s    lbc001c1e
  3126.     move    d5,d0
  3127.     and    #$f020,d0
  3128.     cmp    #$e020,d0    ;asr.b dx,dx
  3129.     bne.s    no_asr_dx_dx
  3130.     and    #$ffc7,d5
  3131.     bra.s    lbc001c2a
  3132.  
  3133. no_asr_dx_dx:
  3134.     cmp    #$e000,d0    ;asr.b #n,dx
  3135.     bne.s    no_asr_n_dx
  3136.     and    #$ffc7,d5
  3137. no_asr_n_dx:
  3138.     and    #$f000,d0
  3139.     cmp    #$7000,d0    ;moveq #n,dx
  3140.     bne.s    no_moveq
  3141.     move.b    #'#',(a3)+
  3142.     move.b    d5,d0
  3143.     ext    d0
  3144.     bpl.s    .posit        ;nombre positif?
  3145.     move.b    #'-',(a3)+      ;si non, prend son opposé et affiche un -
  3146.     neg    d0
  3147. .posit    bra.w    ConvByte    ;et convertit le nombre
  3148. no_moveq:
  3149.     move.b    #'#',(a3)+
  3150.     bsr.w    lbc001e92
  3151.     tst    d1
  3152.     bne.s    conv_byte
  3153.     moveq    #8,d1
  3154. conv_byte:
  3155.     move    d1,d0
  3156.     bsr.w    ConvByte
  3157.     bra.s    lbc001c34
  3158.  
  3159. lbc001c1e
  3160.     move    d6,d0
  3161.     and    #$0030,d0
  3162.     cmp    #$0010,d0
  3163.     bne.s    lbc001c38
  3164. lbc001c2a
  3165.     clr    d0
  3166.     bsr.w    lbc001e92
  3167.     bsr.w    lbc001d32
  3168. lbc001c34
  3169.     move.b    #',',(a3)+
  3170. lbc001c38
  3171.     move    d6,d0
  3172.     and    #4,d0
  3173.     beq.s    get_adr_mode
  3174.     move    d5,d0
  3175.     ext    d0
  3176.     bne.s    lbc001c4a
  3177.     move    (a4)+,d0
  3178.     subq    #2,d0
  3179. lbc001c4a
  3180.     ext.l    d0
  3181.     add.l    a4,d0
  3182.     bra.w    ConvHex32
  3183. ;détermine le mode d'adressage de l'instruction
  3184. get_adr_mode:
  3185.     move    d6,d0
  3186.     and    #$0200,d0    ;mode d(PC) ?
  3187.     beq.s    lbc001c7a
  3188.     move    d5,d0
  3189.     and    #$0400,d0    ;mode d(PC,xn) ?
  3190.     beq.s    lbc001c72
  3191. ;sinon, mode d'adressage immediat
  3192.     move    (a4)+,d0
  3193.     move    d0,-(sp)
  3194.     bsr.b    lbc001c7a
  3195.     move.b    #',',(a3)+
  3196.     move    (sp)+,d0
  3197.     bra.w    lbc001dfe
  3198.  
  3199. lbc001c72
  3200.     bsr.w    lbc001dfc
  3201.     move.b    #',',(a3)+
  3202. lbc001c7a
  3203.     move    d5,d0
  3204.     and    #$fff0,d0
  3205.     cmp    #$4e50,d0    ;link.w ax,#n
  3206.     bne.s    no_link_ax_n
  3207.     btst    #3,d5
  3208.     bne.s    lbc001c9c
  3209.     bsr.b    lbc001c9c
  3210.     move.b    #',',(a3)+
  3211.     move.b    #'#',(a3)+
  3212.     move    (a4)+,d0
  3213.     bra.w    lbc001f2a
  3214.  
  3215. lbc001c9c
  3216.     and    #$ffc7,d5
  3217.     or    #8,d5
  3218. no_link_ax_n:
  3219.     move    d6,d0
  3220.     and    #2,d0
  3221.     beq.w    ret
  3222.     move    d6,d0
  3223.     and    #8,d0
  3224.     beq.s    lbc001cbe
  3225.     bsr.w    lbc001ec2
  3226.     move.b    #',',(a3)+
  3227. lbc001cbe
  3228.     move    d5,d0
  3229.     and    #$003f,d0
  3230.     move    d0,d1
  3231.     cmp    #$003a,d0
  3232.     bne.s    mode_ABSw
  3233. ;mode d'adressage adr(PC)
  3234.     move    (a4)+,d0
  3235.     subq    #2,d0
  3236.     ext.l    d0
  3237.     add.l    a4,d0
  3238.     bsr.w    ConvHex32
  3239.     lea    pc.txt(pc),a0
  3240.     bra.w    cop_str
  3241.  
  3242. mode_ABSw:
  3243.     cmp    #$0038,d0
  3244.     bne.s    mode_ABSl
  3245.     move    (a4)+,d0
  3246.     bsr.w    ConvHex16
  3247.     move.b    #'.',(a3)+
  3248.     move.b    #'W',(a3)+
  3249.     rts
  3250.  
  3251. mode_ABSl:
  3252.     cmp    #$0039,d0
  3253.     bne.s    lbc001d0c
  3254.     move.l    (a4)+,d0
  3255.     bsr.w    ConvHex32
  3256. ;    move.b    #'.',(a3)+
  3257. ;    move.b    #'L',(a3)+
  3258.     rts
  3259.  
  3260. lbc001d0c
  3261.     cmp    #$003c,d0
  3262.     beq.w    lbc001ea6
  3263.     cmp    #$003b,d0
  3264.     beq.s    lbc001d26
  3265.     and    #$0038,d0
  3266.     cmp    #$0038,d0
  3267.     beq.w    lbc001e9e
  3268. lbc001d26
  3269.     move    D1,D0
  3270.     and    #$0038,D0
  3271.     and    #7,D1
  3272.     lsr.b    #3,d0
  3273. lbc001d32
  3274.     dbf    d0,lbc001d3e
  3275. lbc001d36
  3276.     move.b    #'D',(a3)+
  3277.     bra.w    put_digit
  3278.  
  3279. lbc001d3e
  3280.     dbf    d0,lbc001d5a
  3281. lbc001d42
  3282.     cmp.b    #7,d1
  3283.     bne.s    no_sp
  3284.     move.b    #'S',(a3)+
  3285.     move.b    #'P',(a3)+
  3286.     rts
  3287. no_sp:    move.b    #'A',(a3)+
  3288.     bra.w    put_digit
  3289.  
  3290. lbc001d5a
  3291.     dbf    d0,lbc001d6a
  3292. parenth:
  3293.     move.b    #'(',(a3)+
  3294.     bsr.b    lbc001d42
  3295.     move.b    #')',(a3)+
  3296.     rts
  3297.  
  3298. lbc001d6a
  3299.     dbf    d0,lbc001d76
  3300.     bsr.s    parenth
  3301.     move.b    #'+',(a3)+      ;mode (xx)+
  3302.     rts
  3303.  
  3304. lbc001d76
  3305.     dbf    d0,lbc001d80
  3306.     move.b    #'-',(a3)+      ;mode -(xx)
  3307.     bra.s    parenth
  3308.  
  3309. lbc001d80
  3310.     dbf    d0,lbc001d98
  3311.     move    (a4)+,d0
  3312.     btst    #$0f,d6
  3313.     bne.s    lbc001d92
  3314.     bsr.w    lbc001f2a
  3315.     bra.s    lbc001d96
  3316.  
  3317. lbc001d92
  3318.     bsr.w    ConvDec
  3319. lbc001d96
  3320.     bra.s    parenth
  3321.  
  3322. lbc001d98
  3323.     dbf    d0,lbc001de2
  3324.     move.b    1(a4),d0
  3325.     ext    d0
  3326.     beq.s    lbc001da8
  3327.     bsr.w    lbc001f2a
  3328. lbc001da8
  3329.     move.b    #'(',(a3)+
  3330.     bsr.b    lbc001d42
  3331.     move.b    #',',(a3)+
  3332. lbc001db2
  3333.     move.b    (a4),d1
  3334.     lsr.b    #4,d1
  3335.     and    #7,d1
  3336.     btst    #7,(a4)
  3337.     bmi.s    lbc001dc6
  3338.     bsr.w    lbc001d36
  3339.     bra.s    put_size
  3340.  
  3341. lbc001dc6
  3342.     bsr.w    lbc001d42
  3343. put_size:
  3344.     move.b    #'.',(a3)+
  3345.     moveq    #'W',d0
  3346.     move    (a4)+,d1
  3347.     btst    #11,d1
  3348.     beq.s    .put
  3349.     moveq    #'L',d0
  3350. .put    move.b    d0,(a3)+
  3351.     move.b    #')',(a3)+
  3352.     rts
  3353.  
  3354. lbc001de2
  3355.     move    (a4),d0
  3356.     ext    d0
  3357.     bsr.w    lbc001c4a
  3358.     move.b    #'(',(a3)+
  3359.     move.b    #'P',(a3)+
  3360.     move.b    #'C',(a3)+
  3361.     move.b    #',',(a3)+
  3362.     bra.s    lbc001db2
  3363.  
  3364. lbc001dfc
  3365.     move    (a4)+,d0
  3366. ;routine qui s'occupe des MOVEMs
  3367. lbc001dfe
  3368.     move    d5,d1
  3369.     and    #$0038,D1
  3370.     cmp    #$0020,D1
  3371.     bne.s    lbc001e16
  3372.     moveq    #15,d2
  3373. lop_revert:
  3374.     roxr    #1,d0
  3375.     roxl    #1,d1
  3376.     dbf    d2,lop_revert
  3377.     move    d1,d0
  3378. lbc001e16
  3379.     moveq    #0,d1
  3380.     clr.b    d2
  3381.     clr.b    d3
  3382. lbc001e1c
  3383.     btst    d1,d0
  3384.     bne.s    lbc001e24
  3385.     clr.b    d2
  3386.     bra.s    lbc001e52
  3387.  
  3388. lbc001e24
  3389.     addq.b    #1,d1
  3390.     tst.b    d2
  3391.     beq.s    lbc001e4c
  3392.     cmp.b    #8,d1
  3393.     beq.s    lbc001e4c
  3394.     cmp.b    #9,d1
  3395.     beq.s    lbc001e4c
  3396.     cmp.b    #$10,d1
  3397.     beq.s    lbc001e4c
  3398.     btst    d1,d0
  3399.     beq.s    lbc001e4c
  3400.     cmp.b    #'-',d2
  3401.     beq.s    lbc001e54
  3402.     moveq    #'-',d2
  3403.     move.b    d2,(a3)+
  3404.     bra.s    lbc001e54
  3405.  
  3406. lbc001e4c
  3407.     subq.b    #1,d1
  3408.     bsr.b    put_it
  3409.     st    d2
  3410. lbc001e52
  3411.     addq.b    #1,d1
  3412. lbc001e54
  3413.     cmp.b    #$10,d1
  3414.     blt.s    lbc001e1c
  3415.     rts
  3416.  
  3417. put_it:
  3418.     movem.l d0/d1,-(sp)
  3419.     tst.b    d3
  3420.     beq.s    .put_it
  3421.     cmp.b    #'-',d2
  3422.     beq.s    .put_it
  3423.     move.b    #'/',(a3)+
  3424. .put_it moveq    #'D',d0
  3425.     cmp.b    #8,d1
  3426.     blt.s    .put
  3427.     moveq    #'A',d0
  3428. .put    move.b    d0,(a3)+
  3429.     and.b    #7,d1
  3430.     bsr.s    put_digit
  3431.     st    d3
  3432.     movem.l (sp)+,d0/d1
  3433.     rts
  3434.  
  3435. put_digit:
  3436.     moveq    #'0',d0
  3437.     add.b    d1,d0        ;on se met en ascii
  3438.     move.b    d0,(a3)+
  3439.     rts
  3440.  
  3441. lbc001e92
  3442.     move    d5,d1
  3443.     and    #$0e00,d1
  3444.     lsr    #8,d1
  3445.     lsr    #1,d1
  3446.     rts
  3447.  
  3448. lbc001e9e
  3449.     lea    illegalmode7.txt(pc),a0
  3450.     bra.s    cop_str
  3451. ret:    rts
  3452.  
  3453. lbc001ea6
  3454.     move    d6,d0
  3455.     and    #$0800,d0
  3456.     beq.s    lbc001ec2
  3457.     lea    _sr.txt(pc),a0
  3458.     move    d6,d0
  3459.     and    #$00c0,D0
  3460.     cmp    #$00c0,D0
  3461.     bne.s    cop_str
  3462.     addq.l    #3,a0
  3463.     bra.s    cop_str
  3464.  
  3465. lbc001ec2
  3466.     move.b    #'#',(a3)+
  3467.     move    d6,d0
  3468.     and    #$00c0,d0
  3469.     cmp    #$0080,d0
  3470.     bne.s    lbc001ed6
  3471.     move.l    (a4)+,d0
  3472.     bra.s    ConvHex32
  3473.  
  3474. lbc001ed6
  3475.     cmp    #$0040,d0
  3476.     bne.s    lbc001ee0
  3477.     move    (a4)+,d0
  3478.     bra.s    ConvHex16
  3479.  
  3480. lbc001ee0
  3481.     move    (a4)+,d0
  3482.     bra.s    ConvByte
  3483.  
  3484. cop_str:
  3485.     tst.b    (a0)
  3486.     beq.s    ret2
  3487.     move.b    (a0)+,(a3)+
  3488.     bra.s    cop_str
  3489. ret2:    rts
  3490.  
  3491. ConvDec:
  3492.     clr    -(sp)
  3493.     ext.l    d0
  3494.     bpl.s    div_lop
  3495.     move.b    #'-',(a3)+
  3496.     neg.l    d0
  3497. div_lop:
  3498.     divu    #10,d0
  3499.     swap    d0
  3500.     add.b    #'0',d0
  3501.     move    d0,-(sp)
  3502.     clr    d0
  3503.     swap    d0
  3504.     tst    d0
  3505.     bne.s    div_lop
  3506. cop_lop:
  3507.     move    (sp)+,d0
  3508.     beq.s    ret3
  3509.     move.b    d0,(a3)+
  3510.     bra.s    cop_lop
  3511. ret3:    rts
  3512.  
  3513. ConvByte:
  3514.     cmp.b    #9,d0
  3515.     bhi.s    hex_byte
  3516.     add.b    #'0',d0
  3517.     move.b    d0,(a3)+
  3518.     rts
  3519. hex_byte:
  3520.     moveq    #1,d1
  3521.     bra.s    ConvHex
  3522.  
  3523. lbc001f2a
  3524.     movem.l d1/a0/a1,-(sp)
  3525.     tst    d0
  3526.     bpl.s    .positive
  3527.     neg    d0
  3528.     move.b    #'-',(a3)+
  3529. .positive
  3530.     bsr.b    ConvHex16
  3531.     movem.l (sp)+,d1/a0/a1
  3532.     rts
  3533.  
  3534. ConvHex16:
  3535.     moveq    #3,d1
  3536.     bra.s    ConvHex
  3537.  
  3538. ConvHex32:
  3539.     moveq    #7,d1
  3540. ConvHex:
  3541.     move.b    #'$',(a3)+
  3542. ConvHex2:
  3543.     move.l    d2,-(sp)
  3544.     clr    -(sp)
  3545. cv_lop: move.b    d0,d2
  3546.     lsr.l    #4,d0
  3547.     and    #$0f,d2
  3548.     move.b    chiffres_table(pc,d2.w),d2
  3549.     move    d2,-(sp)
  3550.     dbf    d1,cv_lop
  3551. putchr: move    (sp)+,d0
  3552.     beq.s    ret4
  3553.     move.b    d0,(a3)+
  3554.     bra.s    putchr
  3555. ret4:    move.l    (sp)+,d2
  3556.     rts
  3557. chiffres_table:dc.b '0123456789ABCDEF'
  3558.     even
  3559.  
  3560. *** Attendre un clic de souris
  3561. Clik:
  3562.     btst    #6,$bfe001
  3563.     bne.b    Clik
  3564.     rts
  3565.  
  3566. *** redéfinir le keymap
  3567. * ceci est nécessaire car l'Amiga a le clavier usa0 par défaut
  3568. SetMap:
  3569.     IFD    NEWKEYMAP
  3570. ;    lea    conio(a5),a1
  3571. ;    move    #9,28(a1)    ;CD_ASKKEYMAP
  3572. ;    moveq    #32,d0        ;keymap_SIZEOF
  3573. ;    move.l    d0,36(a1)    ;io_length
  3574. ;    lea    KeyMap(a5),a0
  3575. ;    move.l    a0,40(a1)    ;io_data
  3576.     move.l    4.w,a6
  3577. ;    jsr    DoIO(a6)
  3578.  
  3579.     lea    conio(a5),a1
  3580.     move    #10,28(a1)    ;CD_SETKEYMAP
  3581.     moveq    #32,d0        ;keymap_SIZEOF
  3582.     move.l    d0,36(a1)    ;io_length
  3583.     lea    KeyMapData(pc),a0
  3584.     add    #LN_SIZE+4,a0
  3585.     move.l    a0,40(a1)    ;io_data
  3586.     jsr    DoIO(a6)
  3587.     ENDC
  3588.     rts
  3589.  
  3590. CursOff:
  3591.     move.l    a0,-(sp)
  3592.     lea    cursoff.txt(pc),a0
  3593.     bra.s    cu_
  3594. CursOn:
  3595.     move.l    a0,-(sp)
  3596.     lea    curson.txt(pc),a0
  3597. cu_    bsr.s    print
  3598.     move.l    (sp)+,a0
  3599.     rts
  3600.  
  3601. prompt:
  3602.     lea    prompt.txt(pc),a0
  3603.     bra.s    print
  3604. printf:
  3605.     bsr.s    DoFmt
  3606. *** Sortir un texte avec la console
  3607. * <-- a0: adr texte (terminé par 0)
  3608. print:
  3609.     movem.l d0-a6,-(sp)
  3610.     moveq    #-1,d3
  3611. pr    move.l    a0,d2
  3612.     lea    conio(a5),a1
  3613.     move    #3,28(a1)
  3614.     move.l    d2,40(a1)
  3615.     move.l    d3,36(a1)
  3616.     move.l    4.w,a6
  3617.     jsr    DoIO(a6)
  3618.     movem.l (sp)+,d0-a6
  3619.     rts
  3620. * idem mais avec un nbre de caractères donné
  3621. * <-- d0: len
  3622. print2
  3623.     movem.l d0-a6,-(sp)
  3624.     move.l    d0,d3
  3625.     bra.b    pr
  3626.  
  3627. *** Effacer l'écran
  3628. cls:    lea    cls.txt(pc),a0
  3629.     bsr.s    print
  3630.     bra    mainmenu
  3631.  
  3632. * Convertir avec RawDoFmt()
  3633. * <-- a0: format string
  3634. *    a1: adr des données à convertir
  3635. *    a3: adr buffer cible
  3636. DoFmt:
  3637.     movem.l d0-a6,-(sp)
  3638.     lea    .put(pc),a2
  3639.     lea    outbuf(a5),a3
  3640.     move.l    4.w,a6
  3641.     jsr    RawDoFmt(a6)
  3642.     movem.l (sp)+,d0-a6
  3643.     lea    outbuf(a5),a0
  3644.     rts
  3645. .put    move.b    d0,(a3)+
  3646.     rts
  3647.  
  3648.     IFD    CustomPrint
  3649. PrintLine:
  3650.     movem.l d0-a6,-(sp)
  3651.     move.l    a0,a4
  3652.     move.l    rast(a5),a3
  3653.     move.l    gfxbase(a5),a6
  3654.  
  3655.     move.l    conio+24(a5),a0
  3656.     movem    38(a0),d0-d7
  3657.     movem    d0-d7,x_pos(a5)
  3658.     move    54(a0),x_max(a5)
  3659.     move    56(a0),y_max(a5)
  3660.  
  3661.     mulu    y_rsize(a5),d1
  3662.     move    d1,-(sp)
  3663.  
  3664.     moveq    #1,d0
  3665.     move.l    a3,a1
  3666.     jsr    SetAPen(a6)
  3667.  
  3668.     move.l    conio+24(a5),a0
  3669.     addq    #1,40(a0)
  3670.  
  3671.     move    40(a0),d0
  3672.     move    44(a0),d1
  3673.     addq    #1,d1
  3674.     cmp    d1,d0
  3675.     ble.s    .t
  3676.     subq    #2,40(a0)
  3677.  
  3678. ;    moveq    #7,d7
  3679. .scroll
  3680.     move.l    a3,a1
  3681.     moveq    #0,d0
  3682.     move    y_rsize(a5),d1
  3683. ;    moveq    #1,d1
  3684.     movem    x_org(a5),d2-d3
  3685.     movem    x_max(a5),d4-d5
  3686.     jsr    ScrollRaster(a6)
  3687. ;    jsr    WaitTOF(a6)
  3688. ;    dbf    d7,.scroll
  3689. .t
  3690.     move.l    a3,a1
  3691.     moveq    #0,d0
  3692.     move    (sp)+,d1
  3693.     subq    #2,d1
  3694.     jsr    Move(a6)
  3695.     move.l    a4,a0
  3696.     bsr    StrLen
  3697.     move.l    a3,a1
  3698.     jsr    Text(a6)
  3699.  
  3700. .f    movem.l (sp)+,d0-a6
  3701.     rts
  3702.     ENDC
  3703.  
  3704. * Remplacer les codes ascii non-affichables par 'NullChar'
  3705. * <-- a0: adr buffer    d0: taille buf
  3706. Test:
  3707.     movem.l a0/d0-d2,-(sp)
  3708.     subq    #1,d0
  3709. .t    move.b    nullchr(pc),d1    ;caract. de remplacement
  3710.     move.b    (a0)+,d2
  3711.     bclr    #7,d2
  3712.     cmp.b    #$20,d2     ;caract. < à $20(=espace)?
  3713.     bcs.b    .no        ;si oui remplacer
  3714.     move.b    d2,d1
  3715.     btst    #7,-1(a0)
  3716.     beq.b    .no
  3717.     bset    #7,d1
  3718. .no    move.b    d1,-1(a0)
  3719.     dbf    d0,.t
  3720.     movem.l (sp)+,a0/d0-d2
  3721.     rts
  3722. nullchr dc.b    '·',0
  3723.     even
  3724.  
  3725. *** Hex --> HexString
  3726. * <-- d7: long, a1: outputstr
  3727. Long2Hex:
  3728.     movem.l d0-d2/a0,-(sp)
  3729.     moveq    #7,d2
  3730. .bcl    rol.l    #4,d7
  3731.     bsr.b    putc
  3732.     dbf    d2,.bcl
  3733. cf    movem.l (sp)+,d0-d2/a0
  3734.     rts
  3735. * <-- d7: word, a1: outputstr
  3736. Word2Hex:
  3737.     movem.l d0-d2/a0,-(sp)
  3738.     moveq    #3,d2
  3739. .bcl    rol    #4,d7
  3740.     bsr.b    putc
  3741.     dbf    d2,.bcl
  3742.     bra.b    cf
  3743. * <-- d7: byte, a1: outputstr
  3744. Byte2Hex:
  3745.     movem.l d0-d2/a0,-(sp)
  3746.     moveq    #1,d2
  3747. .bcl    rol.b    #4,d7
  3748.     bsr.b    putc
  3749.     dbf    d2,.bcl
  3750.     bra.b    cf
  3751. putc
  3752.     move    d7,d1
  3753.     and    #$f,d1
  3754.     move.b    table_conv(pc,d1.w),(a1)+
  3755.     rts
  3756. table_conv dc.b '0123456789ABCDEF'
  3757.     even
  3758.  
  3759. * Conversion Mot Long-->HexString
  3760. * <-- a0: buffer dest.    d0: mot long à convertir
  3761. HexConv:
  3762.     lea    hbuf(pc),a0
  3763. HexConv2:
  3764.     move.b    #'$',(a0)+
  3765. HexConv0:
  3766.     move.l    d0,d1
  3767.     moveq    #7,d3        ;counter for the nibbles:8-1
  3768. .bcl    rol.l    #4,d1        ;move upper nibble into lower
  3769.     move    d1,d2        ;write in d2
  3770.     bsr.b    nib        ;and convert it
  3771.     move.b    d2,(a0)+    ;character in buffer
  3772.     dbf    d3,.bcl     ;repeat 8 times
  3773.     rts
  3774. HexConvWord:
  3775.     move    d0,d1
  3776.     moveq    #3,d3
  3777. .bcl    rol    #4,d1
  3778.     move    d1,d2
  3779.     bsr.b    nib
  3780.     move.b    d2,(a0)+
  3781.     dbf    d3,.bcl
  3782.     rts
  3783. HexConvByte:
  3784.     move    d0,d1
  3785.     moveq    #1,d3
  3786. .bcl    rol.b    #4,d1
  3787.     move    d1,d2
  3788.     bsr.b    nib
  3789.     move.b    d2,(a0)+
  3790.     dbf    d3,.bcl
  3791.     rts
  3792. nib
  3793.     and.b    #$0f,d2
  3794.     add.b    #$30,d2
  3795.     cmp.b    #$3a,d2
  3796.     bcs.b    .ok
  3797.     addq.b    #7,d2
  3798. .ok    rts
  3799.  
  3800. *** Longword to DecimalString
  3801. * <-- d0: nbre à convertir
  3802. DecConv:
  3803.     lea    hbuf(pc),a0
  3804. DecConv2:
  3805.     movem.l a1/a2,-(sp)
  3806.     move.l    a0,a2
  3807.     lea    tableconv(pc),a1
  3808.     tst.l    d0
  3809.     bne.b    .non_nul
  3810.     move.b    #$30,(a0)+
  3811.     clr.b    (a0)
  3812.     move.l    a2,a0
  3813.     bra.b    .convend
  3814. .non_nul
  3815.     bpl.b    .pos
  3816.     move.b    #'-',(a0)+              ;nbre négatif
  3817.     neg.l    d0
  3818.     bra.b    .go
  3819. .pos
  3820.     and.l    #$7fffffff,d0        ;valeur positive max.
  3821. .go
  3822.     moveq    #8,d2
  3823.     bsr.b    .nib
  3824.     add.b    #$30,d0
  3825.     move.b    d0,(a0)+
  3826.     clr.b    (a0)
  3827. .convend
  3828.     movem.l (sp)+,a1/a2
  3829. .nozero cmp.b    #$30,(a0)+
  3830.     beq.b    .nozero
  3831.     subq.l    #1,a0
  3832.     move.l    a0,-(sp)
  3833.     moveq    #-1,d0        ;strlen en d0
  3834. .strlen addq.l    #1,d0
  3835.     tst.b    (a0)+
  3836.     bne.b    .strlen
  3837.     move.l    (sp)+,a0
  3838.     rts
  3839. .nib
  3840.     moveq    #0,d3
  3841.     move.l    (a1)+,d1
  3842. .bcl    sub.l    d1,d0
  3843.     bcs.b    .neg
  3844.     addq.l    #1,d3
  3845.     bra.b    .bcl
  3846. .neg    add.l    d1,d0
  3847.     add.b    #$30,d3
  3848.     move.b    d3,(a0)+
  3849.     dbf    d2,.nib
  3850.     rts
  3851. tableconv:
  3852.     dc.l    1000000000
  3853.     dc.l    100000000
  3854.     dc.l    10000000
  3855.     dc.l    1000000
  3856.     dc.l    100000
  3857.     dc.l    10000
  3858.     dc.l    1000
  3859.     dc.l    100
  3860.     dc.l    10
  3861. hbuf    dcb.b    32,0
  3862.     even
  3863.  
  3864. * Conversion Décimal/Hex String --> mot long
  3865. * <-- a0: string adr
  3866. * --> d0: 0 si ok, -1 si erreur
  3867. * --> d1: mot long
  3868. Convert:
  3869.     cmp.b    #'$',(a0)+
  3870.     beq.s    Hex2Long
  3871.     cmp.b    #'%',-1(a0)
  3872.     beq.w    BinString2Long
  3873.     subq.l    #1,a0
  3874.  
  3875.     moveq    #10,d3
  3876. DConv:
  3877.     moveq    #0,d0
  3878.     moveq    #0,d1
  3879.     moveq    #0,d2
  3880.     move.l    d4,-(sp)
  3881.     moveq    #0,d4
  3882.     cmp.b    #'-',(a0)       ;nbre négatif?
  3883.     bne.b    .dconv
  3884.     moveq    #-1,d4
  3885.     addq.l    #1,a0
  3886. .dconv    move.b    (a0)+,d2
  3887.     beq.s    .done
  3888.     cmp.b    #'0',d2
  3889.     bcs.b    .done
  3890.     cmp.b    #'9',d2
  3891.     bhi.b    .done
  3892.     add.l    d0,d0
  3893.     move.l    d0,d1
  3894.     asl.l    #2,d0
  3895.     add.l    d1,d0
  3896.     sub.b    #'0',d2
  3897.     add.l    d2,d0
  3898.     dbf    d3,.dconv
  3899. .done    move.l    d0,d1
  3900.     tst.l    d4
  3901.     beq.b    .pos
  3902.     neg.l    d1        ;nbre négatif
  3903. .pos
  3904.     moveq    #0,d0        ;code de retour: pas d'erreur
  3905.     bra.b    .f
  3906. .no    moveq    #-1,d0        ;erreur
  3907. .f    move.l    (sp)+,d4
  3908.     subq.l    #1,a0
  3909.     rts
  3910.  
  3911. * Conversion HexString --> mot Long
  3912. * <-- a0: buffer HexString
  3913. * --> d0: 0 si ok, -1 si erreur
  3914. * --> d1: mot long
  3915. Hex2Long:
  3916.     moveq    #8,d3
  3917. HConv:
  3918.     moveq    #0,d0
  3919.     moveq    #0,d1
  3920. .hconv    move.b    (a0)+,d0
  3921. ;    beq.s    .err
  3922.     cmp.b    #$20,d0
  3923.     bls.s    .err
  3924.     bsr.s    hval
  3925.     tst.l    d0
  3926.     bmi.s    .err
  3927.     add.l    d0,d1
  3928.     subq    #1,d3
  3929.     beq.s    .fin
  3930.     rol.l    #4,d1
  3931.     bra.s    .hconv
  3932. .fin    moveq    #0,d0
  3933. .f1
  3934.     rts
  3935. .err
  3936.     ror.l    #4,d1
  3937.     subq.l    #1,a0
  3938.     bra.s    .f1
  3939. hval:
  3940.     move.b    d0,d2
  3941.     and.b    #~$20,d2    ;mettre en majusc.
  3942.     cmp.b    #'A',d2
  3943.     blt.b    .nb
  3944.     cmp.b    #'Z',d2
  3945.     bgt.b    .nb
  3946.     cmp.b    #'F',d2
  3947.     bgt.b    .nohex
  3948.     sub.b    #'A'-10,d2
  3949.     move.b    d2,d0
  3950.     rts
  3951. .nb
  3952.     sub.b    #'0',d0
  3953.     blt.b    .nohex
  3954.     cmp.b    #9,d0
  3955.     bgt.b    .nohex
  3956.     rts
  3957. .nohex    moveq    #-1,d0
  3958.     rts
  3959.  
  3960. * Conversion Mot Long -> BinString
  3961. * <-- a0: adr bin-string
  3962. * <-- d1: mot long
  3963. Long2BinString:
  3964.     lea    binbuf(a5),a0
  3965.     movem.l d1-d4/a0,-(sp)
  3966.     moveq    #3,d4
  3967. .bcl0    moveq    #7,d2
  3968. .bcl    add.l    d1,d1
  3969.     moveq    #24,d3
  3970.     addx.b    d3,d3
  3971.     move.b    d3,(a0)+
  3972.     dbf    d2,.bcl
  3973.     move.b    #'.',(a0)+
  3974.     dbf    d4,.bcl0
  3975.     clr.b    -1(a0)
  3976.     movem.l (sp)+,d1-d4/a0
  3977.     rts
  3978. * Conversion BinString -> Mot long
  3979. * <-- a0: adr bin-string
  3980. * <-- d1: mot long
  3981. BinString2Long:
  3982.     move.l    d2,-(sp)
  3983.     move.l    a0,-(sp)
  3984.     moveq    #-1,d0
  3985. .lop0    addq.l    #1,d0
  3986.     move.b    (a0)+,d2
  3987.     beq.s    .end
  3988.     cmp.b    #'0',d2
  3989.     beq.s    .lop0
  3990.     cmp.b    #'1',d2
  3991.     beq.s    .lop0
  3992. * ce n'est pas un caractère '1' ou '0' => erreur
  3993.     move.l    (sp)+,a0
  3994.     bra.s    .err
  3995. .end
  3996.     move.l    (sp)+,a0
  3997.     subq    #1,d0
  3998.     moveq    #0,d1
  3999. .lop    move.b    (a0)+,d2
  4000.     sub.b    #$30,d2
  4001.     bmi.s    .err
  4002.     cmp.b    #1,d2
  4003.     bhi.s    .err
  4004.     tst.b    d2
  4005.     beq.s    .clr
  4006.     bset    d0,d1
  4007.     bra.s    .do_lop
  4008. .clr    bclr    d0,d1
  4009. .do_lop subq    #1,d0
  4010.     bpl.s    .lop
  4011. .f    move.l    (sp)+,d2
  4012.     moveq    #0,d0
  4013.     rts
  4014. .err
  4015.     moveq    #0,d1
  4016.     bra.s    .f
  4017.  
  4018. * a0: src string
  4019. * a1: dest string
  4020. StrCpy:
  4021.     movem.l a0/a1,-(sp)
  4022. .copy    move.b    (a0)+,(a1)+
  4023.     bne.s    .copy
  4024.     movem.l (sp)+,a0/a1
  4025.     rts
  4026. * a0: string
  4027. StrLen:
  4028.     move.l    a0,-(sp)
  4029.     moveq    #-1,d0
  4030. .len    addq.l    #1,d0
  4031.     tst.b    (a0)+
  4032.     bne.s    .len
  4033.     move.l    (sp)+,a0
  4034.     rts
  4035.  
  4036. *** Handler Trap
  4037. MyTrap:
  4038. ;    move.l    a0,-(sp)
  4039. ;    move.l    4.w,a0
  4040. ;    move.l    ThisTask(a0),a0
  4041. ;    move.l    4(sp),tc_TrapData(a0)    ;numéro de trap ds tc_TrapData
  4042. ;    move.l    (sp)+,a0
  4043. ;    addq.l    #4,sp
  4044. ;    rte
  4045.  
  4046. *** DATA
  4047. VARS:    dc.l    0
  4048.  
  4049. New.Scr:
  4050.     dc.w    0,0,Width,Height
  4051.     dc.w    Depth
  4052.     dc.b    0,1
  4053.     dc.w    $8000
  4054.     dc.w    $4000!$10f
  4055.     dc.l    topaz8
  4056.     dc.l    0    ;scrtitle
  4057.     dc.l    0,0
  4058. New.Win:
  4059.     dc.w    0,0,0,0
  4060.     dc.b    -1,-1
  4061.     dc.l    $10000!$8000!$400!$40!$10!8
  4062.     dc.l    $1000!$800
  4063.     dc.l    0    ;gagdets
  4064.     dc.l    0
  4065.     dc.l    0    ;scrtitle
  4066.     dc.l    0,0
  4067.     dc.w    0,0,0,0
  4068.     dc.w    $f
  4069.  
  4070. New.Pal:dc.w    $aa9,$000,$fff,$dec
  4071.  
  4072. topaz8: dc.l    topaz.name
  4073.     dc.w    8
  4074.     dc.b    0,0
  4075.  
  4076. illegalmode7.txt:
  4077. ;    dc.b    'ILLEGALMODE7',0
  4078. ;    dc.b    'BADMODE',0
  4079.     dc.b    '???????',0
  4080. _sr.txt:    dc.b    'SR',0
  4081. _ccr.txt:    dc.b    'CCR',0
  4082. _usp.txt:    dc.b    'USP',0
  4083. pc.txt:     dc.b    '(PC)',0
  4084.     even
  4085. instruction_table:
  4086.  dc.w $ff00,$0000,$080b
  4087.  dc.w $f1b8,$0108,$0022
  4088.  dc.w $f1b8,$0188,$0012
  4089.  dc.w $f1c0,$0100,$0012
  4090.  dc.w $f1c0,$0140,$0012
  4091.  dc.w $f1c0,$0180,$0012
  4092.  dc.w $f1c0,$01c0,$0012
  4093.  dc.w $ff00,$0200,$080b
  4094.  dc.w $ff00,$0400,$000b
  4095.  dc.w $ff00,$0600,$000b
  4096.  dc.w $ffc0,$0800,2
  4097.  dc.w $ffc0,$0840,2
  4098.  dc.w $ffc0,$0880,2
  4099.  dc.w $ffc0,$08c0,2
  4100.  dc.w $ff00,$0a00,$080b
  4101.  dc.w $ff00,$0c00,$000b
  4102.  dc.w $f000,$1000,$00c2
  4103.  dc.w $f000,$2000,$0082
  4104.  dc.w $f000,$3000,$0042
  4105.  dc.w $ffc0,$40c0,2
  4106.  dc.w $ff00,$4000,3
  4107.  dc.w $f1c0,$4180,$0022
  4108.  dc.w $f1c0,$41c0,$0032
  4109.  dc.w $ff00,$4200,3
  4110.  dc.w $ffc0,$44c0,2
  4111.  dc.w $ff00,$4400,3
  4112.  dc.w $ffc0,$46c0,2
  4113.  dc.w $ff00,$4600,3
  4114.  dc.w $ffc0,$4800,2
  4115.  dc.w $fff8,$4840,2    ;swap dx
  4116.  dc.w $fff8,$4880,$42    ;ext.w dx
  4117.  dc.w $fff8,$48c0,$82    ;ext.l dx
  4118.  dc.w $ffc0,$4840,2
  4119.  dc.w $ff80,$4880,$0202
  4120.  dc.w $ffff,$4afc,0    ;illegal
  4121.  dc.w $ff00,$4a00,3
  4122.  dc.w $ffc0,$4ac0,2
  4123.  dc.w $ff80,$4c80,$0202
  4124.  dc.w $fff0,$4e40,0    ;trap #n
  4125.  dc.w $fff8,$4e50,2    ;link.w ax,#n
  4126.  dc.w $fff8,$4e58,2    ;unlk ax
  4127.  dc.w $fff0,$4e60,2    ;move.l ax,usp
  4128.  dc.w $ffff,$4e70,0    ;reset
  4129.  dc.w $ffff,$4e71,0    ;nop
  4130.  dc.w $ffff,$4e72,0    ;stop
  4131.  dc.w $ffff,$4e73,$4000 ;rte
  4132.  dc.w $ffff,$4e75,$4000 ;rts
  4133.  dc.w $ffff,$4e76,0    ;trapv
  4134.  dc.w $ffff,$4e77,$4000 ;rtr
  4135.  dc.w $ffc0,$4e80,$a002 ;jsr
  4136.  dc.w $ffc0,$4ec0,$c002 ;jmp
  4137.  dc.w $f0f8,$50c8,2
  4138.  dc.w $ffc0,$51c0,2
  4139.  dc.w $f0c0,$50c0,2
  4140.  dc.w $f100,$5000,$0103
  4141.  dc.w $f100,$5100,$0103
  4142.  dc.w $ff00,$6100,$2004
  4143.  dc.w $ffff,$6000,$4004 ;bra.w
  4144.  dc.w $ff00,$6000,$4004
  4145.  dc.w $f0ff,$6000,4
  4146.  dc.w $f000,$6000,4
  4147.  dc.w $f100,$7000,$0120
  4148.  dc.w $f1c0,$80c0,$0022
  4149.  dc.w $f1f0,$8100,$1002
  4150.  dc.w $f1c0,$81c0,$0022
  4151.  dc.w $f100,$8000,$0023
  4152.  dc.w $f100,$8100,$0013
  4153.  dc.w $f1c0,$90c0,$0072
  4154.  dc.w $f1c0,$91c0,$00b2
  4155.  dc.w $f130,$9100,$1003
  4156.  dc.w $f100,$9000,$0023
  4157.  dc.w $f100,$9100,$0013
  4158.  dc.w $f1c0,$b0c0,$0072
  4159.  dc.w $f1c0,$b1c0,$00b2
  4160.  dc.w $f100,$b000,$0023
  4161.  dc.w $f138,$b108,$0403
  4162.  dc.w $f100,$b100,$0013
  4163.  dc.w $f1f0,$c100,$1002
  4164.  dc.w $f1c0,$c0c0,$0022
  4165.  dc.w $f1f8,$c140,$0022
  4166.  dc.w $f1f8,$c148,$0032
  4167.  dc.w $f1f8,$c188,$0022
  4168.  dc.w $f1c0,$c1c0,$0022
  4169.  dc.w $f100,$c000,$0023
  4170.  dc.w $f100,$c100,$0013
  4171.  dc.w $f1c0,$d0c0,$0072
  4172.  dc.w $f1c0,$d1c0,$00b2
  4173.  dc.w $f130,$d100,$1003
  4174.  dc.w $f100,$d000,$0023
  4175.  dc.w $f100,$d100,$0013
  4176.  dc.w $ffc0,$e0c0,2
  4177.  dc.w $ffc0,$e1c0,2
  4178.  dc.w $ffc0,$e2c0,2
  4179.  dc.w $ffc0,$e3c0,2
  4180.  dc.w $ffc0,$e4c0,2
  4181.  dc.w $ffc0,$e5c0,2
  4182.  dc.w $ffc0,$e6c0,2
  4183.  dc.w $ffc0,$e7c0,2
  4184.  dc.w $f118,$e000,$0103
  4185.  dc.w $f118,$e100,$0103
  4186.  dc.w $f118,$e008,$0103
  4187.  dc.w $f118,$e108,$0103
  4188.  dc.w $f118,$e010,$0103
  4189.  dc.w $f118,$e110,$0103
  4190.  dc.w $f118,$e018,$0103
  4191.  dc.w $f118,$e118,$0103
  4192.  dc.w 0,0,0        ;fin de la table
  4193. instructions.txt:
  4194.  dc.b 'ORI+MOVEP+MOVEP+BTStBCHgBCLrBSEtANDI+SUBI+ADDI+'
  4195.  dc.b 'BTStBCHgBCLrBSEtEORI+CMPI+'
  4196.  dc.b 'MOVE.bMOVE.lMOVE.wMOVeNEGX+CHkLEaCLR+MOVeNEG+MOVeNOT+'
  4197.  dc.b 'NBCdSWApEXT.wEXT.lPEaMOVEM+ILLEGAlTST+TAsMOVEM+TRApLINk'
  4198.  dc.b 'UNLkMOVeRESEtNOpSTOpRTeRTsTRAPvRTrJSrJMpDB@cSfS@c'
  4199.  dc.b 'ADDQ+SUBQ+BSrBRA.lBRA.sB@C.lB@C.sMOVEqDIVuSBCdDIVsOR+OR+'
  4200.  dc.b 'SUBA.wSUBA.lSUBX+SUB+SUB+CMPA.wCMPA.lCMP+CMPM+EOR+ABCdMULu'
  4201.  dc.b 'EXgEXgEXgMULsAND+AND+ADDA.wADDA.lADDX+ADD+ADD+ASrASlLSrLSl'
  4202.  dc.b 'ROXrROXlROrROlASR+ASL+LSR+LSL+ROXR+ROXL+ROR+ROL+*',0     ;UNKNOWn',0
  4203.  
  4204. topaz.name    dc.b 'topaz.font',0
  4205. gfxname     dc.b 'graphics.library',0
  4206. intname     dc.b 'intuition.library',0
  4207. trackname    dc.b 'trackdisk.device',0
  4208. consolename    dc.b 'console.device',0
  4209.  
  4210. *** messages
  4211. prompt.txt    dc.b '>',$9b,' p',0
  4212. cursoff.txt    dc.b $9b,'0 p',0
  4213. curson.txt    dc.b $9b,' p',0
  4214. cls.txt     dc.b $c,0
  4215. lf.txt        dc.b $a,0
  4216. home.txt    dc.b $9b,'H',0
  4217. space.txt    dc.b ' ',0
  4218. backspace.txt    dc.b 8,' ',8,0
  4219. cursorleft.txt    dc.b $9b,'D',0
  4220. cursorright.txt dc.b $9b,'C',0
  4221. oldcommand.txt    dc.b $d,$9b,'C',0
  4222.  
  4223. main.txt
  4224. ; dc.b $9b,'0x',$9b,'0y'
  4225. ; dc.b $9b,'80u',$9b,'32t'
  4226.  dc.b $9b,'0 p',$9b,'20h'
  4227.  dc.b $9b,'m',$9b,'1;33m',$c
  4228.  DC.B '- RESET-TOOL V1.0 - ©1995-97 by Frédéric BASSALER -'
  4229.  dc.b $9b,'m',$a
  4230.  dc.b 'm [start] [end]         Memory Dump    | '
  4231.  dc.b 'a [start] [end]         Ascii Dump',$a
  4232.  dc.b 'd [start] [end]         Disassemble    | '
  4233.  dc.b 'e <start>               Edit Mem',$a
  4234.  dc.b 'c <start> <end> <dest>  Copy Mem       | '
  4235.  dc.b 'cl <start> <end>        Clear Mem',$a
  4236.  dc.b '< <addr> <offset> <len> Read Diskblocks| '
  4237.  dc.b '> <addr> <offset> <len> Write Diskblcks',$a
  4238.  dc.b '[ [#<addr>] <bytesize>  Alloc[Abs] Mem | '
  4239.  dc.b '] <addr> <bytesize>     Free Mem',$a
  4240.  dc.b 'r                       Show Registers | '
  4241.  dc.b 'du <UnitNumber (0-3)>   Change DiskUnit',$a
  4242.  dc.b 'j[sr] <addr>            JMP/JSR to Addr| '
  4243.  dc.b 'b <addr>                Calc.Blk ChkSum',$a
  4244.  dc.b 'bb <addr>               Calc.BootChkSum| '
  4245.  dc.b 'bm <addr>               Calc.BmapChkSum',$a
  4246.  dc.b 'lm                      List ResModules| '
  4247.  dc.b 'll                      List Libraries',$a
  4248.  dc.b 'ld                      List Devices   | '
  4249.  dc.b 'lr                      List Resources',$a
  4250.  dc.b 'lt                      List Tasks     | '
  4251.  dc.b 'lp                      List Ports',$a
  4252.  dc.b 'li                      List Interrupts| '
  4253.  dc.b 'lM                      List Memory',$a
  4254.  dc.b 'fill <start> <end> <data> Fill Memory  | '
  4255.  dc.b 'find <start> <end> <data> Find data',$a
  4256.  dc.b '<HELP>                  Type this page | '
  4257.  dc.b 'si                      System Info',$a
  4258.  dc.b '? <expr>                Calculate      | '
  4259.  dc.b 'x                       Exit program',$a
  4260.  dc.b 'inst [unit] [FFS]       Install Disk   | '
  4261.  dc.b 'KILL             Remove RT from memory!',$a
  4262.  dc.b $a,'Commands are case sensitive.',$a
  4263.  dc.b $a,$9b,' p',0
  4264.  
  4265. sysinfo.txt
  4266.  dc.b 'CPU: 680%1d0 - FPU: %s',$a
  4267.  dc.b 'KickStart version: %d.%d - Exec version: %d.%d',$a
  4268.  dc.b 'MaxLocMem: %08lx - MaxExtMem: %08lx',$a
  4269.  dc.b 'VBlank: %d Hz - PowerSupply: %d Hz',$a,$a
  4270.  dc.b 'Capture Vectors: Cold  : %08lx Cool  : %08lx Warm  : %08lx',$a
  4271.  dc.b ' Kick   Vectors: MemPtr: %08lx TagPtr: %08lx ChkSum: %08lx',$a,$a
  4272.  dc.b '       Available  Largest',$a
  4273.  dc.b 'Chip  %10.10ld  %10.10ld',$a
  4274.  dc.b 'Fast  %10.10ld  %10.10ld',$a
  4275.  dc.b 'Total %10.10ld',$a,$a
  4276.  dc.b 'Reset-Tool location: %lx-%lx (%d bytes)',$a
  4277.  DC.B 0
  4278. fpu881.txt dc.b '68881',0
  4279. fpu882.txt dc.b '68882',0
  4280. fpu040.txt dc.b '68040',0
  4281. nofpu.txt  dc.b 'None.',0
  4282.  
  4283. lastalert.txt    dc.b 'Last Alert: %08lx.%08lx',$a,0
  4284. badcommand.txt    dc.b '** Unknown command (or unimplemented!)',$a,0
  4285. abort.txt    dc.b '** Aborted!',$a,0
  4286. badargs.txt    dc.b '** Bad args!',$a,0
  4287. badunit.txt    dc.b '** Bad Drive Unit!',$a,0
  4288. alloc.txt    dc.b 'Allocated %ld bytes at %lx',$a,0
  4289. allocerr.txt    dc.b '** Failed to Alloc memory!',$a,0
  4290. diskerr.txt    dc.b '** Disk error!',$a,0
  4291. clrmem.txt    dc.b 'Clearing memory location %lx-%lx',$a,0
  4292. copmem.txt    dc.b 'Copying memory from %lx-%lx to %lx',$a,0
  4293. readblk.txt    dc.b 'Addr:%lx Offset:%ld Len:%ld Unit:%ld',$a,0
  4294. checksum.txt    dc.b 'CheckSum fixed. Old:%08lx New:%08lx',$a,0
  4295. currunit.txt    dc.b 'Current Disk Unit: %ld',$a,0
  4296. uninstall.txt    dc.b $9b,'1;33mTerminating...',$9b,'m',$a,0
  4297.  
  4298. resmods.txt
  4299.  dc.b 'Resident Modules in System:',$a
  4300.  dc.b 'Addr     Pri  Ver Name                      ID String',$a
  4301.  dc.b '-------- ---  --- ----                      ---------',$a,0
  4302. reslibs.txt
  4303.  dc.b 'Resident Libraries in System:',$a
  4304.  dc.b 'Addr     Cnt Ver        Name',$a
  4305.  dc.b '-------- --- --------   ----',$a,0
  4306. resdevs.txt
  4307.  dc.b 'Resident Devices in System:',$a
  4308.  dc.b 'Addr     Cnt Ver        Name',$a
  4309.  dc.b '-------- --- --------   ----',$a,0
  4310. resres.txt
  4311.  dc.b 'Resident Resources in System:',$a
  4312.  dc.b 'Addr     Cnt Ver        Name',$a
  4313.  dc.b '-------- --- --------   ----',$a,0
  4314. port.txt
  4315.  dc.b 'System Ports:',$a
  4316.  dc.b 'Addr     Name                 Flags    SigBit SigTask',$a
  4317.  dc.b '-------- ----                 -------- ------ -------',$a,0
  4318. task.txt
  4319.  dc.b 'System Tasks:',$a
  4320.  dc.b 'Addr     Type    State   Pri  Name',$a
  4321.  dc.b '-------- ------- ------- ---- ----',$a,0
  4322. int.txt
  4323.  dc.b 'System Interrupts:',$a
  4324.  dc.b 'Addr     Code     Data     Pri  Name',$a
  4325.  dc.b '-------- -------- -------- ---- ----',$a,0
  4326. mem.txt
  4327.  dc.b 'Memory List:',$a
  4328.  dc.b 'Node Type Attr  Lower     Upper     Size (kb) Pri  Name',$a
  4329.  dc.b '--------- ----- --------- --------- --------- ---- ----',$a,0
  4330.  
  4331. regs.txt
  4332.  dc.b 'D0: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx',$a
  4333.  dc.b 'A0: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx',$a
  4334.  dc.b 'USP=%08lx SR=%04x',$a
  4335.  dc.b 0
  4336.     even
  4337. regs    ds.l   16
  4338. spreg    dc.l    0
  4339. srreg    dc.w    0
  4340.  
  4341. myresptr dc.l    0
  4342.  
  4343. strbuf    ds.b 512
  4344. strbuflen=*-strbuf
  4345.     even
  4346. oldbuf    ds.b 512
  4347.     even
  4348. hexbuf    ds.b 512
  4349.     even
  4350. editbuf ds.b 69
  4351. editbuflen=*-editbuf
  4352.  
  4353.     even
  4354. *** Programme de boot Standard 2.0+
  4355. bootblock.data:
  4356.     dc.b    'DOS',0
  4357.     dc.l    0,$370        ;chksum, rootblock
  4358.     lea    expansion.name(pc),a1
  4359.     moveq    #37,d0
  4360.     jsr    OpenLibrary(a6)
  4361.     tst.l    d0
  4362.     beq.b    .err
  4363.     move.l    d0,a1
  4364.     bset    #6,34(a1)
  4365.     jsr    CloseLibrary(a6)
  4366. .err    lea    dos.name(pc),a1
  4367.     jsr    -96(a6)
  4368.     tst.l    d0
  4369.     beq.b    .nodos
  4370.     move.l    d0,a0
  4371.     move.l    22(a0),a0
  4372.     moveq    #0,d0
  4373.     rts
  4374. .nodos    moveq    #-1,d0
  4375.     rts
  4376. dos.name    dc.b    'dos.library',0
  4377. expansion.name    dc.b    'expansion.library',0
  4378. bootblock.size=*-bootblock.data
  4379.  
  4380. KeymapData:
  4381.     IFD    NEWKEYMAP
  4382.     incdir    devs:Keymaps/
  4383.     incbin    f
  4384.     ENDC
  4385.  
  4386. End:
  4387.  
  4388.     END
  4389.